LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   blocking socket Vs non-blocking socket (https://www.linuxquestions.org/questions/linux-software-2/blocking-socket-vs-non-blocking-socket-799071/)

barunparichha 03-31-2010 04:12 AM

blocking socket Vs non-blocking socket
 
My question is quite simple:
What are type of applications where socket in blocking mode can be used ?
And where non-blocking mode to be used ??


TCP is blocking by default.

When we are in non-blocking mode, it's a must to check the return values of send and rev, because we might not be able to send/recv the entire chunk of data in single shot.

jayasekar 03-31-2010 04:16 AM

hi barunparichha,
Have a look at http://www.developerfusion.com/artic...on-to-tcpip/8/

barunparichha 03-31-2010 04:31 AM

Can we summarize some situation/env to use blocking/non-blocking mode ?

Bccause in real industry env, it's always to trade off between blocking and non-blocking mode.

chrism01 03-31-2010 10:15 PM

If each incoming msg requires a one-shot (short) piece of processing, then finish, then blocking makes sense. Also if the receiver is a serial worker ie the business requirement only processes msgs in order, then blocking.

If the receiver is also monitoring ongoing processing eg child worker processes, then non-blocking is good. Also if processing incoming msgs in parallel is allowed.


All times are GMT -5. The time now is 08:38 PM.