- documented check (non-blocking open finished)

This commit is contained in:
zolliker
2005-09-09 14:33:07 +00:00
parent c33aa1625c
commit 82b77ee939

View File

@ -321,7 +321,7 @@ CreateSocketAdress(
}
oldopts = fcntl(self->sockid, F_GETFL, 0);
if (! (oldopts | O_NONBLOCK)) {
/* assume success when in blocking bmode */
/* assume success when in blocking mode */
return 1;
}
FD_ZERO(&wmask);
@ -331,17 +331,22 @@ CreateSocketAdress(
iret = select(self->sockid+1, &rmask, &wmask, NULL, &tmo);
if (iret == 0) return 0; /* in progress */
if (iret > 0) {
if (FD_ISSET(self->sockid, &wmask)) {
if (FD_ISSET(self->sockid, &rmask)) {
iret = recv(self->sockid, NULL, 0, 0);
/* the connection has either succeded or failed
- the write flag indicates success
- the read flag indicates, if there is already data pending
the read flag should not appear without the write flag
*/
if (FD_ISSET(self->sockid, &wmask)) { /* should always be true */
if (FD_ISSET(self->sockid, &rmask)) { /* there may already be data for read */
iret = recv(self->sockid, NULL, 0, 0); /* zero length, check only return value */
if (iret >= 0) {
iret = 1;
}
iret = 1; /* success */
} /* else failure */
} else {
iret = send(self->sockid, NULL, 0, 0);
iret = send(self->sockid, NULL, 0, 0); /* zero length, check only return value */
if (iret >= 0) {
iret = 1;
}
iret = 1; /* success */
} /* else failure */
}
}
}