• Post Reply Bookmark Topic Watch Topic
  • New Topic

Operation timed out  RSS feed

 
Gaurav Chikara
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to call constructer of client socket class which creates a Socket
But I am getting the following exception
if i use
E1029H7 instead of www.iit.edu
Exception on socket creation: Connection refused: connect
and if i use www.iit.edu
then i get
Exception on socket creation: Connection timed out:
Here are my codes
public final class Webserver {
public static int PORT = 1026;
public static void main(String[] args) {
try {
HttpRequest httpRequest = new HttpRequest ("www.iit.edu");
}
catch(Exception e){
System.out.println("Exception"+e.getMessage());
}
}
}
and this is my client class

public class HttpRequest {
public Socket socket;
private final int EchoPort = 2777;
public HttpRequest(String hostName) throws Exception
{
try {
System.out.println("reached here 1");
socket = new Socket(hostName,EchoPort);
System.out.println("reached here 2");
}
catch(UnknownHostException e){
throw new Exception("Unknown host: "+e.getMessage());
}
catch(IOException e){
throw new Exception("IOException on socket creation: "+e.getMessage());
}
}
// Close the connection now it is finished with.
echoSocket.close();
}
catch(IOException e){
}
}
protected Socket getSocket(){
return socket;
}
}
Can anyone pls tell me where I might be wrong?
[ September 17, 2002: Message edited by: Gaurav Chikara ]
[ September 17, 2002: Message edited by: Gaurav Chikara ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!