Re: Socket waiting for server

Discussion in 'Java' started by Steve Horsley, Jul 30, 2003.

  1. On Wed, 30 Jul 2003 14:20:54 +0200, Arnaud Berger wrote:

    > Hi everyone !
    >
    > I've got a java application on my machine, which is supposed to launch the
    > "server" part (ServerSocket stuff) and also the "client" part (Socket) of
    > my appli.
    >
    > I obviously encounter a java.net.ConnectException while the server part is
    > not up (doing Socket sock=new Socket(myhost, myPort).
    >
    > The question is, is there a way for me to wait until the server is up and
    > running ?
    > the socket's connect(SocketAddress, timeout) method is of no help for this
    > because the timeout is effective only when the connection has already
    > succeeded.
    >
    > Thanks in advance for any pointer.
    >
    >
    > Arnaud


    The best that I can think of is to use a loop with a sleep if the
    connection fails. Then perhaps rethrow the caught exception if it is still
    failing after a period of time.

    Steve
     
    Steve Horsley, Jul 30, 2003
    #1
    1. Advertising

  2. Thanks everyone

    Arnaud

    "Steve Horsley" <_SPAM.net> a écrit dans le message
    news: _SPAM.net...
    > On Wed, 30 Jul 2003 14:20:54 +0200, Arnaud Berger wrote:
    >
    > > Hi everyone !
    > >
    > > I've got a java application on my machine, which is supposed to launch

    the
    > > "server" part (ServerSocket stuff) and also the "client" part (Socket)

    of
    > > my appli.
    > >
    > > I obviously encounter a java.net.ConnectException while the server part

    is
    > > not up (doing Socket sock=new Socket(myhost, myPort).
    > >
    > > The question is, is there a way for me to wait until the server is up

    and
    > > running ?
    > > the socket's connect(SocketAddress, timeout) method is of no help for

    this
    > > because the timeout is effective only when the connection has already
    > > succeeded.
    > >
    > > Thanks in advance for any pointer.
    > >
    > >
    > > Arnaud

    >
    > The best that I can think of is to use a loop with a sleep if the
    > connection fails. Then perhaps rethrow the caught exception if it is still
    > failing after a period of time.
    >
    > Steve
     
    Arnaud Berger, Jul 30, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. EJP
    Replies:
    1
    Views:
    350
    Steve Horsley
    Aug 1, 2003
  2. Laszlo Nagy
    Replies:
    1
    Views:
    5,122
    Mark Wooding
    Jan 27, 2009
  3. Jean-Paul Calderone
    Replies:
    0
    Views:
    1,034
    Jean-Paul Calderone
    Jan 27, 2009
  4. Laszlo Nagy
    Replies:
    0
    Views:
    601
    Laszlo Nagy
    Feb 1, 2009
  5. Steve Holden
    Replies:
    0
    Views:
    717
    Steve Holden
    Feb 1, 2009
Loading...

Share This Page