下面我已详细分享了我的代码。我阅读文档和关于握手的一切。我遵循了文档中提供的所有步骤以及互联网上的众多示例,但仍然存在此问题。奇怪的事情id websocket.onclsose()在我关闭服务器时被触发。从服务器发送响应握手后,websocket.onopen不会触发
// Simple Websocket server
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.Net;
using System.IO;
using System.Security.Cryptography;
using System.Threading;
namespace WebSocketServer
{
class Program
{
//port
private static int _port = 8181;
static void Main(string[] args)
{
TcpListener t = new TcpListener(IPAddress.Loopback, _port);
t.Start();
Console.WriteLine("Server is started and waiting for client\n\n");
byte[] buff = new byte[255];
NetworkStream stream;
TcpClient clie