public EndPointListener(IPAddress addr, int port, bool secure) { if (secure) { this.secure = secure; LoadCertificateAndKey(addr, port); } endpoint = new IPEndPoint(addr, port); #if SSHARP sock = !addr.Equals(IPAddress.Any) ? new Socket(IPAddress.Any, port, 64, addr.GetAdapterTypeForAddress()) : new Socket(IPAddress.Any, port, 64); sock.Listen(64); #else sock = new Socket(addr.AddressFamily, SocketType.Stream, ProtocolType.Tcp); sock.Bind(endpoint); sock.Listen(500); #endif SocketAsyncEventArgs args = new SocketAsyncEventArgs(); args.UserToken = this; args.Completed += OnAccept; #if SSHARP sock.BeginAccept(acceptCallback, Tuple.Create(sock, args)); #else sock.AcceptAsync(args); #endif prefixes = new Hashtable(); unregistered = new Dictionary <HttpConnection, HttpConnection> (); }