获取客户端IP地址:端口(System.Runtime.Remoting.Channels)
我正在尝试获取客户端 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有理由认为这应该很容易。远程处理通过 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.