所以我使用HttpListener(webSocket)来监听连接。收到连接并触发事件以处理上下文:
private void WebSocketServer_OnWebSocketContext(object sender, System.Net.WebSockets.HttpListenerWebSocketContext context)
{
OnWebSocketContext(context);
}
private async void OnWebSocketContext(System.Net.WebSockets.HttpListenerWebSocketContext context)
{
...
}
我的问题是,如何获取连接机器的IP地址。这一切都是通过浏览器(显然是http)完成的。我无法确定在上下文中找到连接机器的IP地址(或者是它)?
答案 0 :(得分:2)
string ipAddress = httpListenerContext.Request.RemoteEndPoint.Address.ToString();