Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
首先,我不想在生产中这样做!我需要测试其他人在 TCP 之上的协议实现是否会导致问题。
我想反复使用某个出站端口进行多个 TCP 会话。Windows 通常会为每个新会话增加端口,我想绕过它进行测试。如何设置 TcpClient 的出站端口?
根据另一篇文章(Is there a way to specify the local port to used in tcpClient?)。您需要使用带有 a 的构造函数重载IPEndpoint来指定要使用的本地端口。
IPEndpoint