- Sending and reading big data by socket

PDA

View Full Version : Sending and reading big data by socket


cyril
07-24-2004, 09:01 PM
Hi there,

I wonder how to send and receive big data (by chunk) with an unknown
size in an opened socket in C.

For example, my server can send to my client a big binary file. My
client didn't know the size of the file, so how can I check the end of
the file. Is there a way for my client to know if the connexion was
properly close.

Does anyone have a snippet code for sending and receiving huge amount
of data by sockets ? I can't find some.

Thanks for all, (I keep searching :o) )

Phil Frisbie, Jr.
07-24-2004, 09:01 PM
cyril wrote:

> Hi there,
>
> I wonder how to send and receive big data (by chunk) with an unknown
> size in an opened socket in C.
>
> For example, my server can send to my client a big binary file. My
> client didn't know the size of the file, so how can I check the end of
> the file. Is there a way for my client to know if the connexion was
> properly close.

When using a TCP connection and the client is calling recv(), the return value
of recv() will be 0 when the server properly closes the connection.

> Does anyone have a snippet code for sending and receiving huge amount
> of data by sockets ? I can't find some.

They are everywhere... For example, look at the source code for any FTP client
or server.

> Thanks for all, (I keep searching :o) )

--
Phil Frisbie, Jr.
Hawk Software
http://www.hawksoft.com