mirror of
https://github.com/samhocevar/rinetd.git
synced 2025-03-22 15:50:08 +08:00
Only call set FIONBIO on TCP sockets.
This commit is contained in:
parent
6bb27c18a6
commit
6750f65c35
26
rinetd.c
26
rinetd.c
@ -277,6 +277,7 @@ void addServer(char *bindAddress, int bindPort, int bindProto,
|
|||||||
closesocket(fd);
|
closesocket(fd);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bindProto == protoTcp) {
|
if (bindProto == protoTcp) {
|
||||||
if (listen(fd, RINETD_LISTEN_BACKLOG) == SOCKET_ERROR) {
|
if (listen(fd, RINETD_LISTEN_BACKLOG) == SOCKET_ERROR) {
|
||||||
/* Warn -- don't exit. */
|
/* Warn -- don't exit. */
|
||||||
@ -285,10 +286,11 @@ void addServer(char *bindAddress, int bindPort, int bindProto,
|
|||||||
bindAddress, bindPort);
|
bindAddress, bindPort);
|
||||||
closesocket(fd);
|
closesocket(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FIONBIO_ARG_T ioctltmp;
|
||||||
|
ioctlsocket(fd, FIONBIO, &ioctltmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
FIONBIO_ARG_T ioctltmp;
|
|
||||||
ioctlsocket(fd, FIONBIO, &ioctltmp);
|
|
||||||
if (getAddress(connectAddress, &iaddr) < 0) {
|
if (getAddress(connectAddress, &iaddr) < 0) {
|
||||||
/* Warn -- don't exit. */
|
/* Warn -- don't exit. */
|
||||||
syslog(LOG_ERR, "host %s could not be resolved.\n",
|
syslog(LOG_ERR, "host %s could not be resolved.\n",
|
||||||
@ -685,16 +687,18 @@ static void handleAccept(ServerInfo const *srv)
|
|||||||
memcpy(&saddr.sin_addr, &srv->localAddr, sizeof(struct in_addr));
|
memcpy(&saddr.sin_addr, &srv->localAddr, sizeof(struct in_addr));
|
||||||
saddr.sin_port = srv->localPort;
|
saddr.sin_port = srv->localPort;
|
||||||
|
|
||||||
#if defined __linux__
|
if (srv->toProto == protoTcp) {
|
||||||
int tmp = 0;
|
FIONBIO_ARG_T ioctltmp = 1;
|
||||||
setsockopt(cnx->local.fd, SOL_SOCKET, SO_LINGER, &tmp, sizeof(tmp));
|
ioctlsocket(cnx->local.fd, FIONBIO, &ioctltmp);
|
||||||
#elif !defined _WIN32
|
|
||||||
int tmp = 1024;
|
|
||||||
setsockopt(cnx->local.fd, SOL_SOCKET, SO_SNDBUF, &tmp, sizeof(tmp));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
FIONBIO_ARG_T ioctltmp = 1;
|
#if defined __linux__
|
||||||
ioctlsocket(cnx->local.fd, FIONBIO, &ioctltmp);
|
int tmp = 0;
|
||||||
|
setsockopt(cnx->local.fd, SOL_SOCKET, SO_LINGER, &tmp, sizeof(tmp));
|
||||||
|
#elif !defined _WIN32
|
||||||
|
int tmp = 1024;
|
||||||
|
setsockopt(cnx->local.fd, SOL_SOCKET, SO_SNDBUF, &tmp, sizeof(tmp));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
if (connect(cnx->local.fd, (struct sockaddr *)&saddr,
|
if (connect(cnx->local.fd, (struct sockaddr *)&saddr,
|
||||||
sizeof(struct sockaddr_in)) == SOCKET_ERROR)
|
sizeof(struct sockaddr_in)) == SOCKET_ERROR)
|
||||||
|
Loading…
Reference in New Issue
Block a user