Socket Client recieving Multiple Packets

B

Ben

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
 
J

Jack Klein

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 but read their
socket FAQ first.
 
K

Karl Zimmerman

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top