Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Winsock SendData

Status
Not open for further replies.

ranc

Programmer
Oct 29, 2000
9
IL
How can I flush the Winsock SendData function -
I want data sent to take place when the SendData function is called,
not only after returning from the function in which SendData was called.

e.g.
Function A has a SendData call in it.
I don’t want to wait with the SendData until function A finishes its execution, that way I will be able to send data more than once during A’s execution.


10x,
Ran
ran@swapstation.com
 
Hi Ran!

Sockets programs are more efficient when you send larger blocks of data, and not individual characters. The optimum size is usually a little smaller than the MTU (maximum transmission unit) of whatever network medium you're using. Ethernet's is 1476 bytes, so sending 1450 bytes at a time usually results in the best performance. Token-Ring is around 5k, and I think ATM varies depending on network conditions.

I would write a couple of functions -- one to collect bytes from your program, and append them together. Once it gets 1450 bytes, have it call the actual transmission routine. You can also write your own flush routine to send any little bits that might be remaining in your buffer when you're done sending.

I haven't used the Winsock control in a long long time, so I'm not sure how it handles this, but one of the "gotchas" in sockets programming is handling the case where the TCP/IP stack wasn't able to send the complete buffer you wanted it to. You gave it 1450 bytes, but the function indicates that only 550 bytes were sent. The other 900 bytes should remain at the head of the buffer, to be sent on the next go-round.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top