Search code examples
webserver

what is blocking and non-blocking web server, what difference between both?


I have seen many a web framework provide a non-blocking web server, I just want to know what it means.


Solution

  • Using a blocking socket, execution will wait (ie. "block") until the full socket operation has taken place. So, you can process any results/responses in your code immediately after. These are also called synchronous sockets.

    A non-blocking socket operation will allow execution to resume immediately and you can handle the server's response with a callback or event. These are called asynchronous sockets.