Click here to Skip to main content
15,918,742 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralPush Button Color Pin
gc3-Oct-00 4:45
gc3-Oct-00 4:45 
GeneralRe: Push Button Color Pin
Roger3-Oct-00 4:47
Roger3-Oct-00 4:47 
GeneralReally Desperate Spy Modification Pin
Larry3-Oct-00 4:45
Larry3-Oct-00 4:45 
GeneralCase Sensetive ComboBox Selection Pin
nogga3-Oct-00 3:52
nogga3-Oct-00 3:52 
GeneralSTL and dynamic objects Pin
JoJo3-Oct-00 2:47
JoJo3-Oct-00 2:47 
GeneralRe: STL and dynamic objects Pin
Erik Funkenbusch4-Oct-00 13:11
Erik Funkenbusch4-Oct-00 13:11 
GeneralSending data in separate TCP packets using Visual C++ Pin
Sergei2-Oct-00 21:42
Sergei2-Oct-00 21:42 
GeneralRe: Sending data in separate TCP packets using Visual C++ Pin
Member 12089653-Oct-00 4:58
Member 12089653-Oct-00 4:58 
As I'm not aware of the overall purpose of your application it's a little hard to be more specific, but here are a few thoughts.

If you want to send single packets you'll have to use UDP not TCP. There is no way to *guarantee* that TCP/IP packets won't be aggregated, either on your machine, or at some other point along the wire. UDP of course doesn't offer guaranteed delivery so you'll have to engineer that functionality yourself.

Here's a snippet from Warren Young's Winsock Programmers FAQ that you might find helpful:

The whole document is found here

>.3.17 - When should I turn off the Nagle algorithm?
Generally, almost never.

Inexperienced Winsockers usually try disabling the Nagle algorithm when they are trying to impose some kind of packet scheme on a TCP data stream. That is, they want to be able to send, say, two packets, one 40 bytes and the other 60, and have the receiver get a 40-byte packet followed by a separate 60-byte packet. (With the Nagle algorithm enabled, TCP will often coalesce these two packets into a single 100 byte packet.) Unfortunately, this is futile, for the following reasons:

Even if the sender manages to send its packets individually, the receiving TCP/IP stack may still coalesce the received packets into a single packet. This can happen any time the sender can send data faster than the receiver can deal with it.
Winsock Layered Service Providers (LSPs) may coalesce or fragment stream data, especially LSPs that modify the data as it passes.
Turning off the Nagle algorithm in a client program will not affect the way that the server sends packets, and vice versa.
Routers and other intermediaries on the network can fragment packets, and there is no guarantee of "proper" reassembly with stream protocols.
If packet arrives that is larger than the available space in the stack's buffers, it may fragment a packet, queuing up as many bytes as it has buffer space for and discarding the rest. (The remote peer will resend the remaining data later.)
Winsock is not required to give you all the data it has queued on a socket even if your recv() call gave Winsock enough buffer space. It may require several calls to get all the data queued on a socket.
Aside from these problems, disabling the Nagle algorithm almost always causes a program's throughput to degrade. The only time you should disable the algorithm is when some other consideration, such as packet timing, is more important than throughput.

Often, programs that deal with real-time user input will disable the Nagle algorithm to achieve the snappiest possible response, at the expense of network bandwidth. Two examples are X Windows servers and multiplayer network games. In these cases, it is more important that there be as little delay between packets as possible than it is to conserve network bandwidth.

>>
GeneralRe: Sending data in separate TCP packets using Visual C++ Pin
Erik Funkenbusch4-Oct-00 13:16
Erik Funkenbusch4-Oct-00 13:16 
GeneralSEH problem in release mode Pin
Robin2-Oct-00 18:26
Robin2-Oct-00 18:26 
GeneralRe: SEH problem in release mode Pin
Feng Yuan2-Oct-00 19:38
Feng Yuan2-Oct-00 19:38 
GeneralRe: SEH problem in release mode Pin
JoeBloggs5-Oct-00 17:34
JoeBloggs5-Oct-00 17:34 
GeneralHandle to a window Pin
Roger2-Oct-00 5:31
Roger2-Oct-00 5:31 
GeneralRe: Handle to a window Pin
Sam Hobbs2-Oct-00 19:39
Sam Hobbs2-Oct-00 19:39 
GeneralRe: Handle to a window Pin
Roger3-Oct-00 1:13
Roger3-Oct-00 1:13 
GeneralRe: Handle to a window Pin
Frank Deo3-Oct-00 1:37
Frank Deo3-Oct-00 1:37 
GeneralRe: Handle to a window Pin
Roger3-Oct-00 1:38
Roger3-Oct-00 1:38 
GeneralRe: Handle to a window Pin
Frank Deo3-Oct-00 1:44
Frank Deo3-Oct-00 1:44 
GeneralRe: Handle to a window Pin
Roger3-Oct-00 1:47
Roger3-Oct-00 1:47 
GeneralRe: Handle to a window Pin
Roger3-Oct-00 1:55
Roger3-Oct-00 1:55 
GeneralRe: Handle to a window Pin
GBO3-Oct-00 2:55
GBO3-Oct-00 2:55 
GeneralRe: Handle to a window Pin
Roger3-Oct-00 2:58
Roger3-Oct-00 2:58 
GeneralRe: Handle to a window Pin
Sam Hobbs3-Oct-00 8:40
Sam Hobbs3-Oct-00 8:40 
GeneralHowto: assign hotkeys to tab-control Pin
AkelA2-Oct-00 4:53
AkelA2-Oct-00 4:53 
GeneralAbstracting serial and socket ports in a class Pin
Jason2-Oct-00 4:47
Jason2-Oct-00 4:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.