我正在开发一个小型TCP客户端/服务器库.
我在创建客户端并将其连接到服务器时遇到此问题.它给了我这个例外
通常只允许使用每个套接字地址(协议/网络地址/端口)
我的代码是.
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);
}
Run Code Online (Sandbox Code Playgroud)
这是TCPServer
public TCPServer(int listeningPort)
{
this.listeningPort = listeningPort;
tcpListenter = new TcpListener(this.listeningPort);
workers = new List<TCPServerWorker>();
this.keepRunning = false;
}
Run Code Online (Sandbox Code Playgroud)
任何帮助,为什么我得到这个例外
解决了.
我用了
tcpClient = new TcpClient();
tcpClient.Connect(remoteIPAddress, port);
Run Code Online (Sandbox Code Playgroud)