@@ -332,31 +332,23 @@ struct SysListenConfig(ListenConfig):
332
332
let conv_status = inet_pton(address_family, to_char_ptr(addr.ip), ip_buf)
333
333
let raw_ip = ip_buf.bitcast[c_uint]().load()
334
334
335
- print (" inet_pton: " + raw_ip.__str__ () + " :: status: " + conv_status.__str__ ())
336
-
337
335
let bin_port = htons(UInt16(addr.port))
338
- print (" htons: " + " \n " + bin_port.__str__ ())
339
336
340
337
var ai = sockaddr_in(address_family, bin_port, raw_ip, StaticTuple[8 , c_char]())
341
338
let ai_ptr = Pointer[sockaddr_in].address_of(ai).bitcast[sockaddr]()
342
339
343
340
let sockfd = socket(address_family, SOCK_STREAM , 0 )
344
341
if sockfd == - 1 :
345
342
print (" Socket creation error" )
346
- print (" sockfd: " + " \n " + sockfd.__str__ ())
347
343
348
344
var yes : Int = 1
349
- if (
350
- setsockopt(
351
- sockfd,
352
- SOL_SOCKET ,
353
- SO_REUSEADDR ,
354
- Pointer[Int].address_of(yes).bitcast[c_void](),
355
- sizeof[Int](),
356
- )
357
- == - 1
358
- ):
359
- print (" set socket options failed" )
345
+ _ = setsockopt(
346
+ sockfd,
347
+ SOL_SOCKET ,
348
+ SO_REUSEADDR ,
349
+ Pointer[Int].address_of(yes).bitcast[c_void](),
350
+ sizeof[Int](),
351
+ )
360
352
361
353
if bind(sockfd, ai_ptr, sizeof[sockaddr_in]()) == - 1 :
362
354
# close(sockfd)
@@ -368,15 +360,8 @@ struct SysListenConfig(ListenConfig):
368
360
369
361
let listener = SysListener(addr, sockfd)
370
362
371
- print (
372
- " Listening on "
373
- + addr.ip
374
- + " :"
375
- + addr.port.__str__ ()
376
- + " on sockfd "
377
- + sockfd.__str__ ()
378
- + " Waiting for connections..."
379
- )
363
+ print (" 🔥🐝 Lightbug is listening on " + addr.ip + " :" + addr.port.__str__ ())
364
+ print (" Ready to accept connections..." )
380
365
381
366
return listener
382
367
@@ -403,7 +388,7 @@ struct SysConnection(Connection):
403
388
self .fd = fd
404
389
405
390
fn read (self , inout buf : Bytes) raises -> Int:
406
- var new_buf = Pointer[UInt8]().alloc(default_buffer_size)
391
+ let new_buf = Pointer[UInt8]().alloc(default_buffer_size)
407
392
let bytes_recv = recv(self .fd, new_buf, default_buffer_size, 0 )
408
393
if bytes_recv == - 1 :
409
394
print (" Failed to receive message" )
0 commit comments