Fixes bug 205437: socket errors not being reported

This commit is contained in:
Abdulaziz Ghuloum 2008-03-24 00:01:22 -04:00
parent 884f3fe921
commit fc92ec8e9f
3 changed files with 12 additions and 9 deletions

View File

@ -15,19 +15,20 @@
(case-lambda
[(who port)
(let ([s (tcp-server-socket-nonblocking
(or (string->number port)
(or (string->number port)
(error who "invalid port number" port)))])
(printf "Listening on port ~a\n" port)
(call/cc
(lambda (k)
(lambda (k)
(with-exception-handler k
(lambda ()
(lambda ()
(let f ()
(let-values ([(op ip)
(accept-connection-nonblocking s)])
(let ([op (transcoded-port op (native-transcoder))]
[ip (transcoded-port ip (native-transcoder))])
(register-callback op
(lambda ()
(register-callback op
(lambda ()
(display "What's your name? " op)
(let ([name (get-name ip)])
(printf "Connection from ~s\n" name)

View File

@ -2073,7 +2073,7 @@
(define (set-fd-nonblocking fd who id)
(let ([rv (foreign-call "ikrt_make_fd_nonblocking" fd)])
(unless (eq? rv 0)
(io-error who id fd))))
(io-error who id rv))))
(define (socket->ports socket who id block?)
(if (< socket 0)

View File

@ -158,27 +158,29 @@ do_connect(ikptr host, ikptr srvc, int socket_type){
return fix(-1);
}
struct addrinfo* i = info;
int sock = -1;
ikptr sock = fix(-1);
while(i){
if(i->ai_socktype != socket_type){
i = i->ai_next;
} else {
int s = socket(i->ai_family, i->ai_socktype, i->ai_protocol);
if(s < 0){
sock = ikrt_io_error();
i = i->ai_next;
} else {
int err = connect(s, i->ai_addr, i->ai_addrlen);
if(err < 0){
sock = ikrt_io_error();
i = i->ai_next;
} else {
sock = s;
sock = fix(s);
i = 0;
}
}
}
}
freeaddrinfo(info);
return fix(sock);
return sock;
}
ikptr