a.sin_port = htons((short) port);
}
+ {
+ int i = 1;
+ ioctl(s, FIONBIO, &i);
+ }
+
if ((
#ifdef IPV6
connect(s, ((addr->family == AF_INET6) ?
connect(s, (struct sockaddr *) &a, sizeof(a))
#endif
) < 0) {
- /*
- * FIXME: We are prepared to receive EWOULDBLOCK here,
- * because we might want the connection to be made
- * asynchronously; but how do we actually arrange this in
- * Unix? I forget.
- */
- if ( errno != EWOULDBLOCK ) {
+ if ( errno != EINPROGRESS ) {
ret->error = error_string(errno);
return (Socket) ret;
}
noise_ultralight(event);
switch (event) {
-#ifdef FIXME_NONBLOCKING_CONNECTIONS
- case FIXME: /* connected */
- s->connected = s->writable = 1;
- break;
-#endif
case 4: /* exceptional */
if (!s->oobinline) {
/*
}
break;
case 2: /* writable */
- {
+ if (!s->connected) {
+ /*
+ * select() reports a socket as _writable_ when an
+ * asynchronous connection is completed.
+ */
+ s->connected = s->writable = 1;
+ break;
+ } else {
int bufsize_before, bufsize_after;
s->writable = 1;
bufsize_before = s->sending_oob + bufchain_size(&s->output_data);
static void set_rwx(Actual_Socket s, int *rwx)
{
int val = 0;
+ if (!s->connected)
+ val |= 2; /* write == connect */
if (s->connected && !s->frozen)
val |= 1 | 4; /* read, except */
if (bufchain_size(&s->output_data))