Co-Authored By:

Asked by: Ionela Roden
technology and computing databasesWhat is blocking and non blocking socket?
Last Updated: 19th June, 2020
Click to see full answer.
Then, what is a non blocking socket?
Blocking sockets are simple due to their sequential execution. Non-blocking sockets, on the other hand, are non-sequential. They require a different perspective to implement them in programming. In a way, non-blocking socket programs are a little complex and a bit more advanced technique of socket communication.
Likewise, is socket accept blocking? accept() blocks the caller until a connection is present. If no messages space is available at the socket to hold the message to be transmitted, then send() normally blocks. If no messages are available at the socket, the recv call waits for a message to arrive.
One may also ask, how do you set a non blocking socket?
The "non-blocking" mode is set by changing one of the socket's "flags". The flags are a series of bits, each one representing a different capability of the socket. So, to turn on non-blocking mode requires three steps: Call the fcntl() API to retrieve the socket descriptor's current flag settings into a local variable.
What is a blocking function?
A blocking function basically computes forever. That's what it means by blocking. Other blocking functions would wait for IO to occur. a non-blocking IO system means a function starts an IO action, then goes idle then handles the result of the IO action when it happens.