Hi ,This is my first message.
i have two program, client and server ,i want to know how i can tranfer file between client and server?
i write a program that send 4Kb pack to servera and when server read (recive) it then send a message to client that send next pack ,but this way is slow and do not work properly.

Posted on 2002-03-26 00:17:34 by hamed_hhz
Random posted a client server app not too long ago which is pretty straightforward. It sends a 100M file from a server to client and then reports the speed. I get > 1M/s with it.
Posted on 2002-03-26 01:19:00 by grv575
> 5MB/s

Anyway, I see you check if there was a socket
error or if done(0), do you also need to check if
you got the whole packet or is this not done at
the socket level?

Something was bothering me when I started working
on this: How should we properly handle receiving/
sending such large files? When I watch programs
like mirc download large files, there is not a
large file dump at the end of the transfer. Do
they save as they go, how?
Posted on 2002-03-26 02:35:10 by bdjames
The size of the data you receive can be of any size, but you don't have to worry about packets. Packets are at winsock level, you have nothing to do with packets.
You will get the data in pieces depending on the line speed. For local network you may get a lot of data at one time, but for the internet it will be much less. Just specify how many bytes you can handle at most, feed this to recv and it will give you those bytes. Bytes that didn't fit in the buffer are just saved for a later call. Download managers probaly read their buffers full, write that buffer to the end of the file, and read the next buffer.

Here's some more info on the packets:

Posted on 2002-03-26 02:58:35 by Thomas
but pack is mine pack that i defined, and it's a structure :

cmd dd ? ;Command (UPLOAD)
scmd dd ? ;Sub Command (CREATEFILE or WRITEFILE)
Param1 dd ? ;any things (file size,...)
Param2 dd ?
Param3 dd ?
Param4 dd ?
bSize dd ?
Buff db 4*1024 dup(?)
Posted on 2002-03-26 07:30:44 by hamed_hhz
hamed_hhz: be aware that it's very unlikely that your packet will be received in one call. It can be cut into pieces in every possible way so you'll have to buffer it until you received a full package.

Posted on 2002-03-26 07:33:50 by Thomas