×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Apr 2005
    Posts
    19

    One socket for multiple http requests

    Hi to all,

    I managed to establish http connection using socket, sending requests and receiving responses successfully. I do so for achieving doing multiple things on one connection, hopefully.

    But the problem occurring here is that only first request gets correct response data. The next request I send (exactly same as the first request) results nothing happens.

    The byte sent as request is in stringbuffer sb as below
    sb.append("GET /cgi HTTP/1.1\r\n");
    sb.append("Connection: Keep-Alive\r\n");
    sb.append("accept:*/*\r\n");
    sb.append("\r\n");


    It must be something I've done wrong, for I didn't do much socket stuff before.

    I'll be very grateful if someone could give me some advice.

    Thanks in advance

  2. #2
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,697

    Re: One socket for multiple http requests

    hi tiansun,

    try complete sample in that article (from j2me book):
    http://www.samspublishing.com/articl...&seqNum=5&rl=1

    hth,
    regards,
    Peter

  3. #3
    Registered User
    Join Date
    Apr 2005
    Posts
    19

    Re: One socket for multiple http requests

    Thanks peterblazejewicz.

    I've read that article. It shows how to establish a socket connection to a http web server to retrieve data. I have done this part successfully.

    That's my bad not to have explained my problem clearly.

    I would like to use socket to connect an ordinary http web server, not only finishing just one "request-response" task, but doing http requests multiple times on the current single ocket connection.

    I am not able to get any more data after first "request-response" task completes. I am not even sure if tha't possible to do so.

    Any advice is appreciated.

  4. #4
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,697

    Re: One socket for multiple http requests

    hi,

    isnt' that happenign due to stateless nature of web servers? they usually close connections after flushing data to client,

    I think you are thinking about something like OperaMini (TM here) which uses socket connections but through middle tier: device<>opera gateway <> rest of the world,
    so OperaMini has actively using sockets persinstant connections I guess,

    also remember that is impossible to connect to "just any web server" using Sockets in MIPD 2.0, ports like 80/443/8080 are by default excluded from use with sockets unless application is signed with 3rd party cert,

    regards,
    Peter

Similar Threads

  1. Nokia 6600 Network (Http and Socket) connections do not work!
    By jimmichr in forum Mobile Java Networking & Messaging & Security
    Replies: 11
    Last Post: 2006-07-14, 07:48
  2. Trap HTTP requests of the device...
    By vvsnaresh in forum Symbian
    Replies: 0
    Last Post: 2005-10-17, 09:44
  3. Nokia 6600 Network (Http and Socket) connections do not work!
    By jimmichr in forum Mobile Java General
    Replies: 2
    Last Post: 2003-11-23, 20:42
  4. how to add HTTP header to data sent using socket?
    By smallfish_ntu in forum Symbian Networking & Messaging (Closed)
    Replies: 3
    Last Post: 2003-09-10, 16:35
  5. Replies: 0
    Last Post: 2002-05-09, 12:07

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×