aspose file tools
The moose likes Sockets and Internet Protocols and the fly likes SocketException Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Reply Bookmark "SocketException" Watch "SocketException" New topic
Author

SocketException

nii addy
Greenhorn

Joined: Dec 04, 2001
Posts: 1
Hi
I have written a simple client server program to mimic the core processes of a bank i.e. withraw, deposit etc. The server can handle multiple clients, but when i close down one client window i get the following error.
****************************************************************
java.net.SocketException: Connection reset by peer: JVM_recv in socket input str
eam read
at java.net.SocketInputStream.socketRead(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:86)
at java.net.SocketInputStream.read(SocketInputStream.java:67)
at java.io.InputStreamReader.fill(InputStreamReader.java:173)
at java.io.InputStreamReader.read(InputStreamReader.java:249)
at java.io.BufferedReader.fill(BufferedReader.java:139)
at java.io.BufferedReader.readLine(BufferedReader.java:299)
at java.io.BufferedReader.readLine(BufferedReader.java:362)
at bank.ServerHandler.run(ServerHandler.java:47)
at java.lang.Thread.run(Thread.java:484)
**********************************************************
Can anyone tell me how to solve this problem please.
Thanks
Shubhrajit Chatterjee
Ranch Hand

Joined: Aug 23, 2001
Posts: 356
This occurs when a thread tries to write to a socket which has already been closed at the other end.
------------------
Shubhrajit :-)


Shubhrajit
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Indeed. Having a client hanging up on you is a legitimate error condition and the resulting exception is something you'll simply have to catch and handle (clean up what needs cleaning up and otherwise ignore it is often sufficient).
On a completely different note, I suggest that ServerHandler should not extend Thread, but simply implement Runnable. That way, you can more easily fit a thread pool into your server later if need be.
- Peter
 
IntelliJ Java IDE
 
subject: SocketException
 
Threads others viewed
Java socket server running from witin weblogic
Read timed out
SocketException: Software caused connection abort: recv failed
Unusual Error while starting weblogic 9.2
Thread locked at BufferedReader.readLine
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com