posted 21 years ago
1)I have written a SocketServer on one machine which
a.Waits for a connection from a client
b.Sends a message to the client using a PrintWriter
c.Receives a message from the client using a BufferedReader
2)On another machine I have a client program which
a.Creates a connection with the server
b.Receives the message from the server using a BufferedReader
c.Sends a message to the server using a PrintWriter
My intention was for the tasks executed in the following order:-
1a,2a,1b,2b,2c,1c
Instead, when run the following happens
1a,2a
And then the client stalls (blocking I think).
The following scenarios were tried to ascertain the problem (but to no avail)
A)If I keep the server code the same but comment out step 2b from the client code, the following happens (with 1b, 2b missing)
1a,2a,2c,1c
B) If I keep the server code the same but comment out step 2a from the client code the following happens (with 1c, 2c missing)
1a,2a,1b,2b
C)Keeping the client code the same but comment out step 1b from the server code only following occurs, (with 1b, 1c, 2b, 2c missing)
1a,2a
D)Keeping the client code the same but commenting out step 1c from server results in 1c missing ie
1a,2a,1b,2b,2c
What is the problem? It seems like there is blocking going on somewhere. Is it not possible for a server and client to communicate backwards and forwards?
If necessary, please mention and I will post the code.
Thanks in advance,