Reputation: 6433
Amazingly, I have had a hard time finding an answer to this..
I have a TCP client socket that I can successfully connect with and send data through. However, after sending data, I'm expecting a response to be returned from the server. I checked my socket and it would appear that it is in non blocking mode.
if (fcntl(sc->connect_d, F_GETFL) && O_NONBLOCK)
{
//non blocking
}
What is the macro for enabling blocking mode so I can read the server response a little easier? Can somebody give me a small snippet that can do this? Thanks
Upvotes: 1
Views: 2633
Reputation: 73051
if (fcntl(sc->connect_d, F_GETFL) && O_NONBLOCK)
The above code is incorrect. It should be:
if (fcntl(sc->connect_d, F_GETFL) & O_NONBLOCK)
Note that TCP sockets are created in blocking mode by default, so (assuming you created the socket yourself) you shouldn't need to do anything to "put it into" blocking mode.
Upvotes: 5