mirror of
https://github.com/simh/simh.git
synced 2026-02-06 00:15:40 +00:00
SOCKET: Implement missing non-blocking for TCP sockets opened with connect
Outbound connections are rare and most may have wanted explicit blocking behavior, so no one noticed the missing non-blocking case. Any place which did do outbound connects have explicitly added SIM_SOCK_OPT_BLOCKING so that the prior behavior is preserved. The SIM_SOCK_OPT_BLOCKING flag is no honored as it was originally intended to be.
This commit is contained in:
11
sim_sock.c
11
sim_sock.c
@@ -917,7 +917,7 @@ if (sta == SOCKET_ERROR) /* bind error? */
|
||||
if (!(opt_flags & SIM_SOCK_OPT_BLOCKING)) {
|
||||
sta = sim_setnonblock (newsock); /* set nonblocking */
|
||||
if (sta == SOCKET_ERROR) /* fcntl error? */
|
||||
return sim_err_sock (newsock, "fcntl");
|
||||
return sim_err_sock (newsock, "setnonblock");
|
||||
}
|
||||
sta = listen (newsock, 1); /* listen on socket */
|
||||
if (sta == SOCKET_ERROR) /* listen error? */
|
||||
@@ -989,7 +989,7 @@ if (!(opt_flags & SIM_SOCK_OPT_BLOCKING)) {
|
||||
sta = sim_setnonblock (newsock); /* set nonblocking */
|
||||
if (sta == SOCKET_ERROR) { /* fcntl error? */
|
||||
p_freeaddrinfo (result);
|
||||
return sim_err_sock (newsock, "fcntl");
|
||||
return sim_err_sock (newsock, "setnonblock");
|
||||
}
|
||||
}
|
||||
if ((!(opt_flags & SIM_SOCK_OPT_DATAGRAM)) && (opt_flags & SIM_SOCK_OPT_NODELAY)) {
|
||||
@@ -1007,6 +1007,11 @@ if (!(opt_flags & SIM_SOCK_OPT_DATAGRAM)) {
|
||||
if (sta == -1)
|
||||
return sim_err_sock (newsock, "setsockopt KEEPALIVE");
|
||||
}
|
||||
if (!(opt_flags & SIM_SOCK_OPT_BLOCKING)) {
|
||||
sta = sim_setnonblock (newsock); /* set nonblocking */
|
||||
if (sta == SOCKET_ERROR) /* fcntl error? */
|
||||
return sim_err_sock (newsock, "setnonblock");
|
||||
}
|
||||
sta = connect (newsock, result->ai_addr, result->ai_addrlen);
|
||||
p_freeaddrinfo (result);
|
||||
if (sta == SOCKET_ERROR) {
|
||||
@@ -1076,7 +1081,7 @@ if (connectaddr != NULL) {
|
||||
if (!(opt_flags & SIM_SOCK_OPT_BLOCKING)) {
|
||||
sta = sim_setnonblock (newsock); /* set nonblocking */
|
||||
if (sta == SOCKET_ERROR) /* fcntl error? */
|
||||
return sim_err_sock (newsock, "fcntl");
|
||||
return sim_err_sock (newsock, "setnonblock");
|
||||
}
|
||||
|
||||
if ((opt_flags & SIM_SOCK_OPT_NODELAY)) {
|
||||
|
||||
Reference in New Issue
Block a user