mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-09 14:07:34 +02:00
fix to use max-connections arg, and changing bind and listen to return booleans
This commit is contained in:
parent
f19e55cf2a
commit
3b116b3189
3 changed files with 4 additions and 4 deletions
|
@ -43,5 +43,5 @@ sexp sexp_listen (sexp ctx, sexp self, sexp arg0, sexp arg1) {
|
|||
if (res >= 0)
|
||||
fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK);
|
||||
#endif
|
||||
return sexp_make_integer(ctx, res);
|
||||
return (res == 0) ? SEXP_TRUE : SEXP_FALSE;
|
||||
}
|
||||
|
|
|
@ -78,12 +78,12 @@
|
|||
(error "couldn't create socket for: " addrinfo))
|
||||
((not (set-socket-option! sock level/socket socket-opt/reuseaddr 1))
|
||||
(error "couldn't set the socket to be reusable" addrinfo))
|
||||
((negative? (bind sock
|
||||
((not (bind sock
|
||||
(address-info-address addrinfo)
|
||||
(address-info-address-length addrinfo)))
|
||||
(close-file-descriptor sock)
|
||||
(error "couldn't bind socket for: " addrinfo))
|
||||
((negative? (listen sock 100))
|
||||
((not (listen sock max-connections))
|
||||
(close-file-descriptor sock)
|
||||
(error "couldn't listen on socket for: " addrinfo))
|
||||
(else
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
;;> Bind a name to a socket.
|
||||
|
||||
(define-c int bind (int sockaddr int))
|
||||
(define-c errno bind (int sockaddr int))
|
||||
|
||||
;;> Listen on a socket.
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue