我们正在尝试使用 WebSockets 将网页连接到服务器 - 请查看是否有任何错误,提前致谢
c#
public static void Main()
{
TcpListener server = new TcpListener(IPAddress.Parse("ws://127.0.0.1"), 9122);
server.Start();
Console.WriteLine("Server has started on 192.168.1.102.{0}Waiting for a connection...", Environment.NewLine);
TcpClient client = server.AcceptTcpClient();
Console.WriteLine("A client connected.");
}
js
var exampleSocket = new WebSocket("ws://127.0.0.1:9122", "protocolOne");
exampleSocket.onopen = function (event) {
exampleSocket.send("Here's some text that the server is urgently awaiting!");
console.log(`gdsfgdsfg`);
}