This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Sockets and Internet Protocols and the fly likes SocketException: Too many open files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "SocketException: Too many open files" Watch "SocketException: Too many open files" New topic
Author

SocketException: Too many open files

Andres Delrotti
Ranch Hand

Joined: Aug 11, 2005
Posts: 136
Javaranch....I have another problem....

I have a running thread which connect to a socket port of a certain URL and reads incoming messages from the connected host port. The code basically goes like this:

This is done inside the run method of the thread


while (true) {
try {
Socket socket = new Socket(hostname, Integer.parseInt(port));
InputStreamReader input = new InputStreamReader
socket.getInputStreamReader());
BufferedReader in = new BufferedReader(input);
while (connected) {
if (in.ready()){
int charMsg = in.read();
// do processes
}
}
catch (SocketException ex) {
e.printStackTrace();
}
}


If ever the host is down....it catches the SocketException prints the exception and goes back to the nex iteration of the while true loop...until the host becomes available again.

Whenever the host becomes unavailble and I check the stack trace... I always get the Exception: SocketException (too many open files). What could be the cause of this? Can anyone enlighten me on this?
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8843
    
    7

This article may help you out


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SocketException: Too many open files
 
Similar Threads
Send a String to Server and server send it somewhere on network
Reading from Streams during connection timeout
Help Debugging my TCP client server program to solve the producer consumer problem
HELP!!! Socket Connection Timeout Problem
SocketException is not throwing in Windows Vista while network lost.