wood burning stoves 2.0*
The moose likes Sockets and Internet Protocols and the fly likes Socket connect timed out and connection refuse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Socket connect timed out and connection refuse" Watch "Socket connect timed out and connection refuse" New topic
Author

Socket connect timed out and connection refuse

piyush shirke
Greenhorn

Joined: Aug 19, 2011
Posts: 1
Hi,

I have the following piece of code
InetAddress addr = InetAddress.getByName(server.getHost());
int port = Integer.parseInt(server.getPort());
SocketAddress sockaddr = new InetSocketAddress(addr, port);
socket = new Socket();
socket.connect(sockaddr, 5000);


When I run it as standalone java application(jar) trying to connect to the server(down). It throws IO Exception with message "connect timed out" . The exception is thrown after 5 secs.

When the application(jar) is loaded from jvm.dll(native code) trying to connect to the server(down). It throws IOException with message "Connection refused: connect"
The issue with this is exception is thrown immediately within a second.

The whole logic is based on the timeout parameter. Does anyone have idea what could be the reason of different behavior Or How to resolve this issue ?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Socket connect timed out and connection refuse
 
Similar Threads
Problem with Whois port on the InterNIC Server
retrieve images from the web
Connecting Sockets thru Proxy
Socket Programming
Socket Time Out