Hey gang, I don't usually ask programming questions of my own on here, but this one happens to be driving me up one wall and down the other. Consider a C++ program that creates a connecting socket and a Python program with a listening socket. The C++ program and the Python program exchange data over that socket. If both ends send data every once in a while, everything continues to flow smoothly. However, if at some point the C++ end sends a small packet and waits for the remote Python end to do something with the data and send it back, the Python end never gets it. The things I have done:
1) Put the C++ program's send() in a proper loop so it will continue sending until the entire send string is sent.
2) Set both the C++ and PYthon sockets nonblocking
3) Disabled Nagle's algorithm on the C++ (sending) end
The possibilities that I can think of:
1) The C++ (sending) end is still buffering the data, and won't send it until something else is added behind it to kick it into the network. This seems odd.
2) The data's actually getting lost. This seems unlikely.
3) The Python end is getting part of the message, but isn't deciding to expose it to the use. I'm using recv() with a max size of 1024, and it's definitely getting no part of the incoming message
Any ideas? Anything I can do to make sure the sending buffer is flushed or the receiving end dumps out the data? Where do you think the problem is happening? Should I make the receiving end fetch recv() with a max size of 1? That doesn't sound like a good idea. Thanks in advance.
PS - Googling "socket flush C++" yields no end of posts that suggest I'm probably missing a trick somewhere.
1) Put the C++ program's send() in a proper loop so it will continue sending until the entire send string is sent.
2) Set both the C++ and PYthon sockets nonblocking
3) Disabled Nagle's algorithm on the C++ (sending) end
The possibilities that I can think of:
1) The C++ (sending) end is still buffering the data, and won't send it until something else is added behind it to kick it into the network. This seems odd.
2) The data's actually getting lost. This seems unlikely.
3) The Python end is getting part of the message, but isn't deciding to expose it to the use. I'm using recv() with a max size of 1024, and it's definitely getting no part of the incoming message
Any ideas? Anything I can do to make sure the sending buffer is flushed or the receiving end dumps out the data? Where do you think the problem is happening? Should I make the receiving end fetch recv() with a max size of 1? That doesn't sound like a good idea. Thanks in advance.
PS - Googling "socket flush C++" yields no end of posts that suggest I'm probably missing a trick somewhere.