Results 1 to 1 of 1
Thread: Request-Reply With Java Sockets
- 03-03-2010, 07:11 PM #1Member
- Join Date
- Mar 2010
- Rep Power
Request-Reply With Java Sockets
I would like to know how to handle request reply properly to a single socket connection.
Here 's my scenario, i am trying to send messages to a socket and i am using Sockets to establish connection to it
Here's a sample scenario,
Thread 1 --> Establish Connection --> Write Message 1 --> Receive Response 2
Thread 2 --> Establish Connection --> Write Message 2 --> Receive Response 1
What happens is, the connections are exchanging replies with each other.
Socket 1 tends to read the replies coming from thread 2 and Socket 2 receives replies from thread 1.
One thing I could do is create a separate receiver thread running rather than waiting for the reply coming from the socket.
How do I ensure that i only get the reply from which I sent, One thing i could do is to synchronize socket access but this would result to slower performance
Here is the scenario that i wish to have
Thread 1 --> Establish Connection --> Write Message 1 --> Receive Response 1
Thread 2 --> Establish Connection --> Write Message 2 --> Receive Response 2
Need your help
- By Camzie in forum NetBeansReplies: 3Last Post: 12-22-2009, 05:39 PM
- By SteroidalPsycho in forum New To JavaReplies: 3Last Post: 10-21-2009, 08:28 AM
- By mohamed sherif in forum New To JavaReplies: 3Last Post: 12-02-2008, 08:05 PM
- By rameshraj in forum Threads and SynchronizationReplies: 1Last Post: 06-11-2008, 06:13 PM