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.
当我使用 TcpClient 类建立到服务器的 tcp 连接时,有没有办法找出这个连接的源端口?我正在尝试实现 exec 协议,而 stderr 端口似乎总是源端口 + 1。
((IPEndPoint) tcpClient.Client.LocalEndPoint).Port建立连接后使用。
((IPEndPoint) tcpClient.Client.LocalEndPoint).Port
解决了 :)
客户端发送标准错误端口的 TCP 端口号(十进制 ascii,空终止)。如果第一个字节为 NULL,则服务器不会进行任何 stderr 连接。