hello. I'm experiencing some problems with sockets.
I'm trying to make a concurrent server to accept more than one clients.
When a client connects to the server, the server creates a new
thread and listens to the socket.
Then, if the client sends something, the server must read it.
On the client i just open a dictionary (txt form) and i send it over the socket.
The problem is that when i read the content of the socket (on the server side) it throws the following exception:
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:189)
at java.net.SocketInputStream.read(SocketInputStream.java:121)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:283)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:325)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177)
at java.io.InputStreamReader.read(InputStreamReader.java:184)
at java.io.BufferedReader.fill(BufferedReader.java:154)
at java.io.BufferedReader.readLine(BufferedReader.java:317)
at java.io.BufferedReader.readLine(BufferedReader.java:382)
at RunnableThread.run(RunnableThread.java:38)
at java.lang.Thread.run(Thread.java:722)
at RunnableThread.<init>(RunnableThread.java:16)
at KnockKnockServer.main(KnockKnockServer.java:56)
where line 38 is " s = brIn.readLine(); "
the code is (just to document my statements):
SERVER
CLIENT
I just want to send the content of the file to the server side (which are just strings). I think my code its all right but it stills keep throwing that exception no matter what i do.
Thanks in advance.
Kind regards