在本地主机上使用 WebsocketSharp 的 websocket 服务器和客户端

时间:2021-06-10 14:17:15

标签: c# websocket-sharp

我正在尝试在同一台设备 (localhost) 上使用 WebsocketSharp 编写一个简单的客户端-服务器应用程序,但我一直收到“不是 Websocket 握手响应。

客户端设置如下:

$url = "https://requiredurl";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPGET, 1);
$data = curl_exec($ch);
curl_close($ch);
header("location: returnurl");      
exit();

也尝试过 /WebSocket

服务器是这样设置的

private const int _port = 555;
 private static WebSocket _ws = new WebSocket("ws://" + IPAddress.Loopback.ToString() + $":{_port}/websocket" );

谢谢

0 个答案:

没有答案