Added tcp-connect-nonblocking which is line tcp-connect but puts the

socket in nonblocking mode.  An operation that would block now
raises (continuable) a condition of type &i/o-would-block which
contains the port in question.  There's no way to handle the
condition gracefully yet.
This commit is contained in:
Abdulaziz Ghuloum
2007-12-27 22:08:27 -05:00
parent fc2d958419
commit 64dac92831
7 changed files with 131 additions and 75 deletions
+16 -5
View File
@@ -33,6 +33,7 @@ ikrt_io_error(){
case EFAULT : return fix(-19);
case EEXIST : return fix(-20);
case EINVAL : return fix(-21);
case EAGAIN : return fix(-22); /* hardcoded in ikarus.io.ss */
}
return fix(-1);
}
@@ -166,9 +167,19 @@ ikrt_tcp_connect(ikptr host, ikptr srvc, ikpcb* pcb){
return fix(sock);
}
//ikptr
//ikrt_tcp_connect(ikp host, ikp port, ikpcb* pcb){
//
//}
ikptr
ikrt_tcp_connect_nonblocking(ikptr host, ikptr srvc, ikpcb* pcb){
ikptr fdptr = ikrt_tcp_connect(host, srvc, pcb);
int fd = unfix(fdptr);
if(fd >= 0){
/* connected alright */
int err = fcntl(fd, F_SETFL, O_NONBLOCK);
if(err == -1){
ikptr errptr = ikrt_io_error();
close(fd);
return errptr;
}
}
return fdptr;
}