G
Guest
I have a server and client that I've written in .NET using the System.Net.Sockets objects, and I am having a bit of a problem. First let me describe what the programs do. The server takes an arbitrary message, encrypts it using a CryptoStream into a MemoryStream, gets an array of bytes from the MemoryStream, and then transmits then length of the encrypted data, followed by the encrypted data down the socket. The client does the exact opposite, reading a 4-byte integer to get the length of the encrypted data, then reading that much data off the socket
On the server, the messages that are being pumped out are put on a queue so that the code using the server will not block while waiting for the message to be sent. So I try filling up the queue with a few hundred messages, and the server starts firing them off as fast as it can. The client keeps up with this for a short duration but inevitably crashes at some point because of an IOException or serialization error.
The only way I have been able to keep a lid on things so far is to have the server wait for the client to send an acknowledgement byte back to the server once it has successfully read the message from the socket. If I do this I get every message flawlessly, but it seems like there is a better way to handle this, I just have not been able to find it
Any help would be GREATLY appreciated
On the server, the messages that are being pumped out are put on a queue so that the code using the server will not block while waiting for the message to be sent. So I try filling up the queue with a few hundred messages, and the server starts firing them off as fast as it can. The client keeps up with this for a short duration but inevitably crashes at some point because of an IOException or serialization error.
The only way I have been able to keep a lid on things so far is to have the server wait for the client to send an acknowledgement byte back to the server once it has successfully read the message from the socket. If I do this I get every message flawlessly, but it seems like there is a better way to handle this, I just have not been able to find it
Any help would be GREATLY appreciated