As of now, my program basically works like this:
Server: Listen for a connection
Client: Request a connection
Server: Accept connection
Client: Send message
Client: Wait for response
Server: Processes message
Server: Send response
I want my client to also listen for message from the server. And these message can happen at any time. When you do something like:
Expand|Select|Wrap|Line Numbers
- ...
- public final void listen(Socket s)
- {
- InputStream in = s.getInputStream();
- int aByte;
- while((aByte=in.read())!=-1)
- {
- //Do stuff
- }
- }
- ...
Is there any way to guarantee that?
I could open up two connections, one for sending and one for receiving. Is that frowned upon? It seems like a wast of resources.