Socket Client recieving Multiple Packets

Discussion in 'C++' started by Ben, Sep 11, 2004.

  1. Ben

    Ben Guest

    Hello all,

    I've got a fairly specific problem, and I'm hoping that somebody will
    have had to do something similar in the past and can help me out.

    I'm trying to write a client for a socket program in c++ to be
    compiled and run on UNIX. To test it out, I have been trying to
    connect to various webpages and simply print the html code to the
    screen. The problem that I'm running into is that I'm butting up
    against the maximum number of bytes that can be crammed into a packet.
    That's to say... some of the webpages that I try to look at are too
    large to fit into one packet.

    Is there a way to recieve multiple packets from a server? To this
    point, I have been able to connect to the server, send the request,
    and do a 'recv()'. Is there a way to recieve more than one packet?

    Thank you very much,
    Ben
     
    Ben, Sep 11, 2004
    #1
    1. Advertising

  2. Ben

    Jack Klein Guest

    On 10 Sep 2004 18:32:39 -0700, (Ben) wrote in
    comp.lang.c++:

    > Hello all,
    >
    > I've got a fairly specific problem, and I'm hoping that somebody will
    > have had to do something similar in the past and can help me out.
    >
    > I'm trying to write a client for a socket program in c++ to be
    > compiled and run on UNIX. To test it out, I have been trying to
    > connect to various webpages and simply print the html code to the
    > screen. The problem that I'm running into is that I'm butting up
    > against the maximum number of bytes that can be crammed into a packet.
    > That's to say... some of the webpages that I try to look at are too
    > large to fit into one packet.
    >
    > Is there a way to recieve multiple packets from a server? To this
    > point, I have been able to connect to the server, send the request,
    > and do a 'recv()'. Is there a way to recieve more than one packet?
    >
    > Thank you very much,
    > Ben


    The C++ language has no sockets, no support for networking at all in
    fact. All such features are platform-specific extensions, not a part
    of the language.

    You need to take this to news:comp.unix.programmer, but read their
    socket FAQ first.

    --
    Jack Klein
    Home: http://JK-Technology.Com
    FAQs for
    comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
    comp.lang.c++ http://www.parashift.com/c -faq-lite/
    alt.comp.lang.learn.c-c++
    http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html
     
    Jack Klein, Sep 11, 2004
    #2
    1. Advertising

  3. In article <>,
    (Ben) wrote:

    > I'm trying to write a client for a socket program in c++ to be
    > compiled and run on UNIX. To test it out, I have been trying to
    > connect to various webpages and simply print the html code to the
    > screen. The problem that I'm running into is that I'm butting up
    > against the maximum number of bytes that can be crammed into a packet.
    > That's to say... some of the webpages that I try to look at are too
    > large to fit into one packet.
    >
    > Is there a way to recieve multiple packets from a server? To this
    > point, I have been able to connect to the server, send the request,
    > and do a 'recv()'. Is there a way to recieve more than one packet?


    Jack is right, this is a platform-related question; but the short answer
    is "yes; do multiple calls to 'recv()' (or 'read()')". Note that
    different session-layer protocols (like HTTP) have different rules on
    how to tell you have read all of the data you can expect; you'll have to
    read the HTTP RFC in order to get full details, but a short-short answer
    is, you're done when
    (a) the connection closes (recv/read will fail), or
    (b) you've read the number of bytes indicated in the Content-Length:
    header, or
    (c) you've read the last "chunk" of a chunk-encoded page.

    -- Karl
     
    Karl Zimmerman, Sep 27, 2004
    #3
    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. Abraham Khalil
    Replies:
    0
    Views:
    415
    Abraham Khalil
    Jan 26, 2004
  2. Rich DeMarinis
    Replies:
    1
    Views:
    2,095
    Gordon Beaton
    Oct 25, 2004
  3. antoine
    Replies:
    3
    Views:
    4,841
    antoine
    Dec 7, 2005
  4. Mitch
    Replies:
    13
    Views:
    1,233
    Mitch
    Mar 10, 2006
  5. Tomas Christiansen

    Send all packets (socket programming)

    Tomas Christiansen, May 22, 2005, in forum: Python
    Replies:
    0
    Views:
    403
    Tomas Christiansen
    May 22, 2005
Loading...

Share This Page