Hi. I write out the java nio server, which is a kind of auction house. My task is to implement this with an infinite pool of items using the following definitions:
- auctioners can join the auction at any time
- The informations about the item and it's current price is send to newly come auctioners
- If the price has changed course this information is sent to all auctioners
- At the end of the auction information about the winner is mailed to all users, who participated in the auction
And the question - is there some kind of "socket listener" that would let the client know if something appeared on the socket? Do you have ideas on how we could implement it well? (Of course, always remains an infinite loop and check if there is something, but it is inelegant and inefficient)
I am afraid you misunderstood me... I have a selector in server's code. What I meant by asking this question was scanning the socket at client's side. Unless You suggest to make another selector in client's code... Is it possible? If I make a selector and socket channels in at client's side then wouldn't the client be another server? Is that what you meant? If so, then how to bind corresponding socket channels? Because I will have couple of clients and each of them will have exactly one socket connected to corresponding server's socket channel.