version 1.96, 2016/03/16 15:41:11 |
version 1.97, 2016/08/09 12:09:40 |
|
|
|
|
FILE *cin, *cout; |
FILE *cin, *cout; |
|
|
|
static int |
|
connect_sync(int s, const struct sockaddr *name, socklen_t namelen) |
|
{ |
|
struct pollfd pfd[1]; |
|
int error = 0; |
|
socklen_t len = sizeof(error); |
|
|
|
if (connect(s, name, namelen) < 0) { |
|
if (errno != EINTR) |
|
return -1; |
|
} |
|
|
|
/* An interrupted connect(2) continues asyncronously. */ |
|
pfd[0].fd = s; |
|
pfd[0].events = POLLOUT; |
|
for (;;) { |
|
if (poll(pfd, 1, -1) == -1) { |
|
if (errno != EINTR) |
|
return -1; |
|
continue; |
|
} |
|
if (getsockopt(s, SOL_SOCKET, SO_ERROR, &error, &len) < 0) |
|
return -1; |
|
if (error != 0) |
|
errno = error; |
|
break; |
|
} |
|
return (error ? -1 : 0); |
|
} |
|
|
char * |
char * |
hookup(char *host, char *port) |
hookup(char *host, char *port) |
{ |
{ |
|
|
} |
} |
} |
} |
#endif /* !SMALL */ |
#endif /* !SMALL */ |
while ((error = connect(s, res->ai_addr, res->ai_addrlen)) < 0 |
error = connect_sync(s, res->ai_addr, res->ai_addrlen); |
&& errno == EINTR) { |
|
; |
|
} |
|
if (error) { |
if (error) { |
/* this "if" clause is to prevent print warning twice */ |
/* this "if" clause is to prevent print warning twice */ |
if (verbose && res->ai_next) { |
if (verbose && res->ai_next) { |
|
|
} else |
} else |
goto bad; |
goto bad; |
|
|
while (connect(data, (struct sockaddr *)&data_addr, |
if (connect_sync(data, (struct sockaddr *)&data_addr, |
data_addr.su_len) < 0) { |
data_addr.su_len) < 0) { |
if (errno == EINTR) |
|
continue; |
|
if (activefallback) { |
if (activefallback) { |
(void)close(data); |
(void)close(data); |
data = -1; |
data = -1; |