获取客户端IP地址:端口(System.Runtime.Remoting.Channels)

发布于 2024-08-18 16:49:54 字数 225 浏览 6 评论 0原文

我正在尝试获取客户端 IP 地址和内部集合的端口。我找到了这个答案。然而,这似乎比我简单地获取客户端的 IP 地址和 IP 地址所需的要多得多。港口。还有其他方法可以做到这一点吗?

I am trying to get a Client IP address & port for an internal collection. I found this answer. However, this seems like a lot more than what I need to simply grab the client's IP address & port. Are there any other ways to do this?

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

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

发布评论

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

评论(1

真心难拥有 2024-08-25 16:49:54

没有理由认为这应该很容易。远程处理通过 TCP、HTTP 和 IPC 通道进行工作。传输机制被抽象出来,因此它们不会妨碍使用远程处理。对于 TCP 通道,实际套接字由 TcpClientSocketHandler 和 TcpServerSocketHandler 类管理。它们是.NET框架中的内部密封类,您无法从自己的代码中访问它们。

链接帖子中的代码对我来说看起来不错,它是框架代码的直接副本。我建议你尝试一下。

There is little reason to assume that it should be easy. Remoting works over TCP, HTTP and IPC channels. The transport mechanisms are abstracted away so they don't get in the way of using Remoting. For a TCP channel, the actual socket is managed by the TcpClientSocketHandler and TcpServerSocketHandler classes. They are internal sealed classes in the .NET framework, you can't get to them from your own code.

The code in the linked post looks okay to me, it is a direct copy of the framework code. I'd recommend you try it.

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