Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }