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 ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
  • 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
Exception on socket creation: Connection refused: connect
and if i use
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 ("");
catch(Exception e){
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.
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
    Bookmark Topic Watch Topic
  • New Topic