Hello All,
Im working on a socket listener that has to listen on 2 ports for 2 types of data( port 80 and port 81). These data are very similar as in the kind of operations that are performed on the data and are just different because they arrive n different ports. I went ahead and coded an implementation using Java's ServerSocket class, only to realize later that the accept() method of the ServerSocket class is block and my implementation cant afford that. So now i was thinking of implementing the same using Java NIO but after having gone through some tutorials i think i am more confused than how i started. It would be great if someone here could walk me through the whole process, even of it be in pseudo code or jus technical "what to do next"'s. This is what i plan to achieve.
Listen, like for ever on 2 ports by calling 2 similar threads.(non blocking) A remote device from some network location connects, sends data and then disconnects.
I think if only knowledge of how NIO can be used to set up a server to listen on a port say port 80, on localhost,is achieved, the rest is all pretty easy to implement.
Cheers