0

everytime it is getting the same error like java.net.SocketException

in java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(Unknown Source)
    at java.net.SocketInputStream.read(Unknown Source)
    at java.net.SocketInputStream.read(Unknown Source)
    at java.io.FilterInputStream.read(Unknown Source)
    at Server.TcpServer.main(TcpServer.java:37)
my code at the following line....

phonenumber = Long.parseLong(query, inFromTcpClient.read());
thanks in advance...
user3004271
  • 9
  • 1
  • 2

2 Answers2

0

It sounds like you have not put your .accept in to a loop, which means the connection between the client and server is being as eclipse says reset as all it does is connect, then disconnect.

Generally its like

try {
    while (true) {
        Socket socket = server.accept();
        // do something with socket (and close it afterwards!)
    }
} catch (InterruptedException ex) {
    // we're outta here!
}
Peter_James
  • 647
  • 4
  • 14
0

To resolve this issue, the client needs to run their Command Prompt in Administrator mode, and type the command:

netsh advfirewall set global StatefulFTP disable 

This should prevent the instance of java.net.Socket from prematurely closing its connection.

check this link also

Ashish
  • 1,943
  • 2
  • 14
  • 17