Advertisement

How tosend/recv bigger than 32768...

Started by October 04, 2002 05:46 PM
9 comments, last by TheTempest 22 years, 4 months ago
Hello again, I have a simple question, that do to my lack of experience, eloudes me...How do i send and recv with buffers bigger than 32768 bytes (32k)? Thanks This applys because i''m writting a FTP program for those of you who wonder how a packet should be bigger than 32k "There are no such things as stupid questions... Just stupid people " -Me
"There are no such things as stupid questions...Just stupid people :)"-Me
32768 bytes? Are you writing 16-bit code?

For regular sockets and TCP you should be able to use buffers that are several megabytes without problems. Just increase the buffer size.

[edited by - spock on October 4, 2002 7:04:16 PM]
Advertisement
I''m not sure where your buffer size limitation comes from... you won''t receive the whole thing in one go anyway, so you will keep recv-ing into a growing buffer, I expect.

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files | My stuff ]
My guess...and a very hazardous guess....
He is trying to send lots and lots of data at once over a non-blocking socket, but the winsock internal buffer for the socked is set at 32k...so the send() call would be returning with 32k of data sent...
But, just a guess!
yes that is correct, i''m trying to write a FTP program and some files can be 500MB''s

NE ideas?

THANKS

"There are no such things as stupid questions...
Just stupid people "
-Me
"There are no such things as stupid questions...Just stupid people :)"-Me
I''m no networking expert, but shouldn''t you be sending small packets? (E.g. not trying to send 32k at once)
||--------------------------||Black Hole Productionshttp://bhp.nydus.netResident expert on stuffmax621@barrysworld.com||--------------------------||
Advertisement
Um, don''t send the whole file at once? Large packets will be split up by routers and so on anyway, so it''s not going to be any easier.

Try something like this:

char buffer[1024];
while( !feof(fp) )
{
size_t num = fread( buffer, 1, sizeof(buffer), fp );
send( sock, buffer, num, 0 );
}




If I had my way, I''d have all of you shot!


codeka.com - Just click it.

Just interested...
Does the code you sent really work?
I mean if the router runs the loop 100 times/second and I have only a 56k modem and can''t receive the data fast enough. Will there be some packages lost if I use TCP or what will happen to it?

conQuest: Interplanetary Wars
http://www.terradesign.ws
quote:
Original post by Daywalker313
Just interested...
Does the code you sent really work?
I mean if the router runs the loop 100 times/second and I have only a 56k modem and can''t receive the data fast enough. Will there be some packages lost if I use TCP or what will happen to it?



No, TCP uses an algorithm known as "sliding-window" to ensure that no data is lost due to one host being slower than the other. This algorithm sort of throttles the faster end to be the same speed as the slower end.

Basically when the receiving end sends an ACK it sends with it the remaining size of it''s internal buffer so the sender knows to only send that much until it gets another ACK. This is all handled by the TCP/IP stack itself and what happens in your application is that the call to send will block until the other end has enough buffer space to hold the data.


If I had my way, I''d have all of you shot!


codeka.com - Just click it.

*lol* I didn''t know that before, my receive-send app. was about 700 lines long because it checked each package and sent a confirmation.
I wondered why there had never any package been lost :D.


conQuest: Interplanetary Wars
http://www.terradesign.ws

This topic is closed to new replies.

Advertisement