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:
@@ -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 */
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user