Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Operation timed out

 
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
if you think brussel sprouts are yummy, you should try any other food. And this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic