//Edit 13:25
Client Console
Connect to server<br />
Repsonded: Tue May 22 13:23:28 CEST 2012<br />
Disconnect to server<br />
Connect to server<br />
Not run: java.net.SocketException: Software caused connection abort: recv failed<br />
Disconnect to server<br />
Connect to server<br />
Not run: java.net.SocketException: Software caused connection abort: recv failed<br />
Disconnect to server<br />
Connect to server<br />
Repsonded: Tue May 22 13:23:38 CEST 2012<br />
Disconnect to server<br />
Connect to server<br />
Not run: java.net.SocketException: Software caused connection abort: recv failed<br />
Disconnect to server<br />
Connect to server<br />
Not run: java.net.SocketException: Software caused connection abort: recv failed<br />
Disconnect to server<br />
Connect to server<br />
Not run: java.net.SocketException: Software caused connection abort: recv failed<br />
Disconnect to server<br />
Connect to server<br />
Not run: java.net.SocketException: Software caused connection abort: recv failed<br />
Disconnect to server<br />
Connect to server<br />
Not run: java.net.SocketException: Software caused connection abort: recv failed<br />
Disconnect to server<br />
Connect to server<br />
Not run: java.net.SocketException: Software caused connection abort: recv failed<br />
Disconnect to server<br />
Connect to server<br />
Not run: java.net.SocketException: Software caused connection abort: recv failed<br />
Disconnect to server<br />
Connect to server<br />
Not run: java.net.SocketException: Software caused connection abort: recv failed<br />
Disconnect to server<br />
Connect to server<br />
Not run: java.net.SocketException: Software caused connection abort: recv failed<br />
Disconnect to server<br />
Connect to server<br />
Not run: java.net.SocketException: Software caused connection abort: recv failed<br />
Disconnect to server<br />
Server Console
Server Initialized<br />
111111<br />
111111<br />
111111<br />
111111<br />
111111<br />
111111<br />
111111<br />
111111<br />
111111<br />
111111<br />
111111<br />
Error(run): java.net.SocketException: Connection reset by peer: socket write error<br />
Server load data and not return repead "Repsonded: Tue May 22 13:23:38 CEST 2012" or client not ouput print.
The problem lies in your server implementation. You are not looping in the run statement, checking for new incomming messages from that connection. You read the information once and then close the connection in the finally statement:
Sure, your server has a loop checking for incomming connection requests, so this would work if the client tries to connect to the server again after each message is sent, but your client only sends one request (in the beginning of the main statement).
So, what I would advice you to do:
Server-side, setup the streams etc in the
runstatement, and once they are set up enter a infinte loop withwhile(true), and in that loop have the server read from the input stream, and ifread()does not return null, print the message. This will cause the server check for incomming data from that client, once you get a string that’s not null it will print it (and trigger a response if you want).Same goes for client side, you need a loop that listens for incomming messages from the server