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...
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!
}
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.