Jillika Iyer wrote:Hi,
What is blocking and non-blocking server in Java? How do you create it?
I have never used the java.nio package and documentation I found online was very confusion.
I have previously only used java.net - ServerSocket and Socket to create communication between simple applications like a chat client etc. but never saw the necessity to use java.nio.
What is the plus point of using java.nio??
A blocking read is ... well... you read the socket, and if there is data, you get it. And if there isn't data, then you wait for the data. A non-blocking read is ... you don't wait for the data if none is available. With non-blocking reads you can read from more than one socket at a time. For example, you open 10 network connections, and you can use the nio library to read from all ten at the same time.
Henry