0

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..

4

1 回答 1

0

您可能会发现正在发生的一件事是其中一个套接字未正确关闭。套接字的问题是您需要确保它们正确关闭,或者您将服务器套接字设置为重用地址。

从 sysinternals 尝试 tcpview 来查看套接字的状态。您还可以使用 netstat 查看套接字的状态。

于 2009-05-08T22:39:39.090 回答