This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Sockets and Internet Protocols and the fly likes java.net.ConnectException: Connection refused: connect Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "java.net.ConnectException: Connection refused: connect" Watch "java.net.ConnectException: Connection refused: connect" New topic
Author

java.net.ConnectException: Connection refused: connect

Nikhil Jain
Ranch Hand

Joined: May 15, 2005
Posts: 385
Hi,

I have a small client-server component.
.i.e. I create a serversocket & then call accept on it (Multithreaded).

I am writing a client which calls the server in a loop. When I call the server, i sometimes get
java.net.ConnectException: Connection refused: connect

Is this due to fact that the client is sending request to the server that is faster that the server can accept connections??

When I slowed down the request by putting some sort of sleep in my client, the occurence of the above exception was less?

for (i = 0; i < 500; i++, j++)
if (j == 50) {
Thread.sleep(1000);
k=0
}
//call server code here
}

What is the limit of the java socket server to accept connections?


SCJP 1.4, SCWCD 1.4, SCBCD 1.5
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Is your server processing the request on the same thread that accepts connections? That would cause slower performance and might get bad enough to refuse connections. This kind of thing is typical:

You can do even cooler things with NIO.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.net.ConnectException: Connection refused: connect
 
Similar Threads
RMI Exception
ConnectRefused in RMI
help me to solve this error
Catalina.stop: java.net.ConnectException: Connection refused: connect
java.rmi.ConnectException: Connection refused to host