views:

404

answers:

1

I'm using the following TCP Sockets Server/Client example: http://www.codeguru.com/Csharp/Csharp/cs_network/sockets/article.php/c8781/

I'm also using the following CryptoStream example: http://www.obviex.com/samples/Encryption.aspx

Problem: Both Server and Clients communicate perfectly until I Stop the Server socket, wait a minute or so, then start the Server socket. Sometimes but not always I recieve a base64 error in the Encryption.aspx on line 'Convert.FromBase64String(cipherText);'...

I know there is incorrect / corrupted data in the buffer probably left-over from stopping the socket. Then the new data comes in and the error occurs.

Q. Will clearing the 'class SocketPacket; solve this issue?

Q. How do I clear the 'class SocketPacketsocketBuffer'?

Other suggestions are greatly appreciated..

A: 

One of the things you may find is happening is that one of the sockets is not being closed down properly. The thing with sockets is that you need to make sure they get correctly closed or you set the server socket to reuse the address.

Try tcpview from sysinternals to view the status of sockets. You can also use netstat to view the status of the sockets.

Nick R