public WebSocketServer(int port, string location) { var uri = new Uri(location); Port = uri.Port > 0 ? uri.Port : port; Location = location; _scheme = uri.Scheme; var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP); ListenerSocket = new SocketWrapper(socket); }
public WebSocketServer(int port, string location) { var uri = new Uri(location); Port = uri.Port > 0 ? uri.Port : port; Location = location; _scheme = uri.Scheme; var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP); ListenerSocket = new SocketWrapper(socket); }
public void Setup() { _listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP); _endpoint = new IPEndPoint(IPAddress.Loopback, 45982); _listener.Bind(_endpoint); _listener.Listen(10); _client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP); ThreadPool.QueueUserWorkItem(x => { Thread.Sleep(100); _client.Connect(_endpoint); }); _socket = _listener.Accept(); _wrapper = new SocketWrapper(_socket); }