fix to use max-connections arg, and changing bind and listen to return booleans

This commit is contained in:
Alex Shinn 2011-11-22 20:15:59 +09:00
parent f19e55cf2a
commit 3b116b3189
3 changed files with 4 additions and 4 deletions

View file

@ -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;
}

View file

@ -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

View file

@ -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.