what is TCP blocking and non-blocking mode in socket module in python3
what is TCP blocking and non-blocking mode in socket module in python
I am trying to understand what it means and under which situation we should use it. I am not able to find a proper example to understand it. I really appreciate if any example can be shared to understand it better.
A non-blocking socket, never blocks, which is the basis of event looping.
For example, the high speed Apache Event MPM, so in this case, rather than one connection/process you have one process for all connections, which dramatically speeds up request processing... which is what makes the entire HTTP/2 protocol process all requests in parallel.
If you're really interested in this topic, take a look at the entire HTTP/2 protocol.
You can also take a look at the many PERL async libraries.
Tip: Python, PERL, C, C++, Ruby, whatever... Sockets are Sockets... all the same in any language...
agreed. just to clear things up, select, kevent and othet related calls also work on blocking sockets. I usually run my first benchmarks in blocking mode which helps to check for mistakes in async programs.
The non blocking sockets allows to do A poor man's async programming without using such system calls, by manually polling file descriptors.
So basically blocking or non blocking is not really about asynchronous programming.
Event driven, mpm, http2 are completely off topic.
A non-blocking socket, never blocks, which is the basis of event looping.
For example, the high speed Apache Event MPM, so in this case, rather than one connection/process you have one process for all connections, which dramatically speeds up request processing... which is what makes the entire HTTP/2 protocol process all requests in parallel.
If you're really interested in this topic, take a look at the entire HTTP/2 protocol.
You can also take a look at the many PERL async libraries.
Tip: Python, PERL, C, C++, Ruby, whatever... Sockets are Sockets... all the same in any language...