Large files and TCP

CyberDude
06-26-2006, 07:01 PM
I am using the Winsock control with TCP/IP protocol and trying to send 29K file to a client. Not all the file gets there; only 5K. It is a graphics file and when opened, you can see it has become corrupted. I am using what I call the "burst" method of sending. I collect all the binary bits of the graphics file and send them at once. I've had success doing this with files of size 3K. Because of the larger size, do I need to send chunks instead of all at once? Do I need to set up a buffer to receive the data? I thought you can send files of any size with TCP? Any recommendations? Thank you.

dilettante
06-26-2006, 08:52 PM
Yes, you can send large files. I've sent multimegabyte files just fine.

You can't just blast a bunch of bytes at the Winsock control and expect miracles though. About 16K at a blast seems close to optimal, but you have to drive the process by SendComplete events: blast a block, then when that send completes you blast out another.

No point at all in sucking the whole file into memory, read it a chunk at a time. That's why files have the ability to be read other than all at once.

Geeze.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum