Better to set multiple socket flags at once

This commit is contained in:
Toon Schoenmakers 2015-12-22 15:02:37 +01:00
parent 226ef47beb
commit d6f6dba660
1 changed files with 2 additions and 5 deletions

View File

@ -112,11 +112,8 @@ private:
// connection succeeded, mark socket as non-blocking // connection succeeded, mark socket as non-blocking
if (_socket >= 0) if (_socket >= 0)
{ {
// turn socket into a non-blocking socket // turn socket into a non-blocking socket and set the close-on-exec bit
fcntl(_socket, F_SETFL, O_NONBLOCK); fcntl(_socket, F_SETFL, O_NONBLOCK | O_CLOEXEC);
// switch on the close-on-exec bit
fcntl(_socket, F_SETFL, O_CLOEXEC);
// we want to enable "nodelay" on sockets (otherwise all send operations are s-l-o-w // we want to enable "nodelay" on sockets (otherwise all send operations are s-l-o-w
int optval = 1; int optval = 1;