Forums Register Login

Operation timed out

+Pie Number of slices to send: Send
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 ]
A lot of people cry when they cut onions. The trick is not to form an emotional bond. This tiny ad told me:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 949 times.
Similar Threads
Wanted: Minimal Web Server Example
Can't catch Window Close event when trying SocketServer trying to accept connections
why always "socket closed (code=0)"
Database Connection
Constructor
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 11:26:05.