1
0
mirror of https://github.com/simh/simh.git synced 2026-02-28 17:20:20 +00:00

SOCK: Add an option to specify a listen backlog

This commit is contained in:
Mark Pizzolato
2023-06-08 00:53:49 -10:00
parent 2e7a109bb8
commit b2983bd214
2 changed files with 6 additions and 2 deletions

View File

@@ -1045,7 +1045,7 @@ if (!(opt_flags & SIM_SOCK_OPT_BLOCKING)) {
if (sta == SOCKET_ERROR) /* fcntl error? */
return sim_err_sock (newsock, "setnonblock");
}
sta = listen (newsock, 1); /* listen on socket */
sta = listen (newsock, SIM_SOCK_OPT_BACKLOG(opt_flags));/* listen on socket */
if (sta == SOCKET_ERROR) /* listen error? */
return sim_err_sock (newsock, "listen");
return newsock; /* got it! */
@@ -1329,8 +1329,10 @@ int sim_read_sock (SOCKET sock, char *buf, int nbytes)
int rbytes, err;
rbytes = recv (sock, buf, nbytes, 0);
if (rbytes == 0) /* disconnect */
if (rbytes == 0) { /* disconnect */
err = WSAGetLastError ();
return -1;
}
if (rbytes == SOCKET_ERROR) {
err = WSAGetLastError ();
if (err == WSAEWOULDBLOCK) /* no data */

View File

@@ -138,6 +138,8 @@ int sim_addr_acl_check (const char *validate_addr, const char *acl);
#define SIM_SOCK_OPT_DATAGRAM 0x0002
#define SIM_SOCK_OPT_NODELAY 0x0004
#define SIM_SOCK_OPT_BLOCKING 0x0008
#define SIM_SOCK_OPT_SET_BACKLOG(N) ((N) << 16)
#define SIM_SOCK_OPT_BACKLOG(opts) ((((opts) >> 16) == 0) ? 1 : ((opts) >> 16))
SOCKET sim_master_sock_ex (const char *hostport, int *parse_status, int opt_flags);
#define sim_master_sock(hostport, parse_status) sim_master_sock_ex(hostport, parse_status, ((sim_switches & SWMASK ('U')) ? SIM_SOCK_OPT_REUSEADDR : 0))
SOCKET sim_connect_sock_ex (const char *sourcehostport, const char *hostport, const char *default_host, const char *default_port, int opt_flags);