Socket 服务器断开和重新连接缓冲区错误?
我正在使用以下 TCP 套接字服务器/客户端示例: http://www.codeguru.com/Csharp/Csharp/cs_network/sockets/article.php/c8781/
我还使用以下 CryptoStream 示例: http://www.obviex.com/samples/Encryption.aspx
问题:两者服务器和客户端完美通信,直到我停止服务器套接字,等待一分钟左右,然后启动服务器套接字。 有时但并非总是我在 Encryption.aspx 行“Convert.FromBase64String(cipherText);”上收到 Base64 错误...
我知道缓冲区中可能存在停止套接字时留下的不正确/损坏的数据。 然后新数据进来,就会出现错误。
问:将清除 'class SocketPacket; 解决这个问题吗?
问:如何清除“类 SocketPacketsocketBuffer”?
其他建议非常感谢..
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..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能会发现正在发生的事情之一是其中一个套接字未正确关闭。 套接字的问题是您需要确保它们正确关闭,或者您将服务器套接字设置为重用该地址。
尝试从 sysinternals 中使用 tcpview 查看套接字的状态。 您还可以使用 netstat 查看套接字的状态。
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.