-
Notifications
You must be signed in to change notification settings - Fork 0
BIO VS NIO
-
BIO, or Blocking IO, relies on plain sockets used in a blocking mode : when you read, write or do whatever operation on a socket, the called operation will blcok the caller until the operation is completed.
-
In some cases, it's critical to be able to call the operation, and to expect the called operation to inform the caller when the operation is done : the caller can then do something else in the mean time.This is also where NIO offers a better way to handle IO when you have numerous connected sockets : you dn't have to create a specific thread for each connection, you can just use a few threads to do the same job.
3.The big difference between BIO (Blocking IO) and NIO (Non-Blocking IO) is that in BIO, you send a request, and you wait until you get the response. On the server side, it means one thread wil be associated with any incoming connection, so you won't have to deal with the complexity of multiplexing the connections. In NIO, on the other hand, you have to deal with the synchronous nature of a non-blocking system, which means that your application will be invoked when some events occur. In NIO, you don't call and wait for a result, you send a command and you are informed when the result is ready.