Socket question!

Discussion in 'Java' started by Paul Oak, Jun 28, 2004.

  1. Paul Oak

    Paul Oak Guest

    Hi all,

    I would like to execute several HTTP POST requests to my localhost web
    server (IIS 5.0) in a loop. Therefore I create a socket and using the
    BufferedReader and Writer to write and read the reponse from the
    server.
    The problem is that after the first request the Web server closes the
    socket.
    Would you please help me to cope with this problem!
    10x in advance!

    Paul
     
    Paul Oak, Jun 28, 2004
    #1
    1. Advertising

  2. Paul Oak

    Gorf Guest

    "Paul Oak" <> wrote in message
    news:...
    > Hi all,
    >
    > I would like to execute several HTTP POST requests to my localhost web
    > server (IIS 5.0) in a loop. Therefore I create a socket and using the
    > BufferedReader and Writer to write and read the reponse from the
    > server.
    > The problem is that after the first request the Web server closes the
    > socket.
    > Would you please help me to cope with this problem!
    > 10x in advance!


    That's due to HTTP (1.0) being stateless, that is it closes the pipe after
    each request. You may want to see if your server allows this in it's
    config.

    Something similar to:
    <http://httpd.apache.org/docs/keepalive.html>

    --
    Gorf
     
    Gorf, Jun 28, 2004
    #2
    1. Advertising

  3. You should add the header "Connection: Keep-Alive" and use HTTP/1.1

    David

    Paul Oak wrote:
    > Hi all,
    >
    > I would like to execute several HTTP POST requests to my localhost web
    > server (IIS 5.0) in a loop. Therefore I create a socket and using the
    > BufferedReader and Writer to write and read the reponse from the
    > server.
    > The problem is that after the first request the Web server closes the
    > socket.
    > Would you please help me to cope with this problem!
    > 10x in advance!
    >
    > Paul
     
    David Rabinowitz, Jun 28, 2004
    #3
  4. Paul Oak

    iksrazal Guest

    (Paul Oak) wrote in message news:<>...
    > Hi all,
    >
    > I would like to execute several HTTP POST requests to my localhost web
    > server (IIS 5.0) in a loop. Therefore I create a socket and using the
    > BufferedReader and Writer to write and read the reponse from the
    > server.
    > The problem is that after the first request the Web server closes the
    > socket.
    > Would you please help me to cope with this problem!
    > 10x in advance!
    >
    > Paul


    Look at the jakarta commons HttpClient instead of doing your own
    socket class. However, I'm thinking that since http is a stateless
    protocol, you cannot keep a connection open for several invokations.
    I'd be interested in finding out otherwise. Try searching on
    httpclient or posting to the commons mailing list. If you find
    something out, please post to this list.

    HTH

    Outsource to an American programmer living in brazil!
    http://www.braziloutsource.com/
    iksrazal
     
    iksrazal, Jun 28, 2004
    #4
    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. Laszlo Nagy
    Replies:
    1
    Views:
    5,100
    Mark Wooding
    Jan 27, 2009
  2. Jean-Paul Calderone
    Replies:
    0
    Views:
    1,028
    Jean-Paul Calderone
    Jan 27, 2009
  3. Laszlo Nagy
    Replies:
    0
    Views:
    597
    Laszlo Nagy
    Feb 1, 2009
  4. Steve Holden
    Replies:
    0
    Views:
    712
    Steve Holden
    Feb 1, 2009
  5. Steve Holden
    Replies:
    1
    Views:
    756
Loading...

Share This Page