C# 发现 LocalEndPoint AddressFamily 端口号

发布于 2024-08-11 22:54:44 字数 96 浏览 5 评论 0原文

当我使用 TcpClient 类与服务器建立 tcp 连接时,有什么方法可以找出此连接的源端口? 我正在尝试实现 exec 协议,而 stderr 端口似乎始终是源端口 + 1。

When I establish a tcp connection to a server using the TcpClient class, is there any way to find out the source port of this connection?
I am trying to implement the exec protocol and stderr port seems to always be source port + 1.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

哽咽笑 2024-08-18 22:54:44

建立连接后使用 ((IPEndPoint) tcpClient.Client.LocalEndPoint).Port

Use ((IPEndPoint) tcpClient.Client.LocalEndPoint).Port after establishing the connection.

陌生 2024-08-18 22:54:44

解决了:)

客户端发送TCP端口号(十进制
stderr 的 ascii、空终止)
港口。如果第一个字节为 NULL,
那么服务器不会产生任何stderr
连接。

Solved :)

Client sends TCP port number (decimal
ascii, null-terminated) of stderr
port. If the first byte is a NULL,
then server won't make any stderr
connection.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文