TCP 套接字错误:通常每个套接字地址(协议/网络地址/端口)只允许使用一次 [英] TCP Socket Error: Only one usage of each socket address (protocol/network address/port) is normally permitted
本文介绍了TCP 套接字错误:通常每个套接字地址(协议/网络地址/端口)只允许使用一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发一个小的 TCP 客户端/服务器库.
i am developing a small TCP Client/Server lib.
我在创建客户端并将其连接到服务器时遇到了这个问题.它给了我这个例外
i am facing this problem when i create a client and connect it to server. it gives me this exception
通常每个套接字地址(协议/网络地址/端口)只允许使用一次
我的代码是.
public TCPClient(string remoteIPAddress, int port)
{
this.remoteIPAddress = IPAddress.Parse(remoteIPAddress);
this.port = port;
IPEndPoint remoteEndPoint = new IPEndPoint(this.remoteIPAddress, this.port);
tcpClient = new TcpClient(remoteEndPoint);
}
这里是 TCPServer
and here is TCPServer
public TCPServer(int listeningPort)
{
this.listeningPort = listeningPort;
tcpListenter = new TcpListener(this.listeningPort);
workers = new List<TCPServerWorker>();
this.keepRunning = false;
}
为什么我会收到此异常的任何帮助
any help that why i am getting this exception
推荐答案
已解决.
我用过
tcpClient = new TcpClient();
tcpClient.Connect(remoteIPAddress, port);
这篇关于TCP 套接字错误:通常每个套接字地址(协议/网络地址/端口)只允许使用一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文