public SocketService(ISocketEventListener socketEventListener) { _socketEventListener = socketEventListener; _logger = ObjectContainer.Resolve <ILoggerFactory>() .Create(GetType() .FullName); }
/// <summary> /// Create a socket. This starts a thread for background processing, but the thread is mostly paused /// waiting for new requests. /// </summary> public HttpSocket(ISocketEventListener listener) : base(listener) { m_thread = new Thread(new ThreadStart(ProcessThread)); m_thread.Name = "HTTP processing thread"; m_thread.IsBackground = true; m_thread.Start(); }
public SocketRemotingServer(string name, SocketSetting socketSetting, ISocketEventListener socketEventListener = null) { _serverSocket = new ServerSocket(socketEventListener); _requestHandlerDict = new Dictionary<int, IRequestHandler>(); _logger = ObjectContainer.Resolve<ILoggerFactory>().Create(name ?? GetType().Name); _serverSocket.Bind(socketSetting.Address, socketSetting.Port).Listen(socketSetting.Backlog); _started = false; }
public ServerSocket(ISocketEventListener socketEventListener) { _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); _socketEventListener = socketEventListener; _socketService = new SocketService(socketEventListener); _newClientSocketSignal = new ManualResetEvent(false); _logger = ObjectContainer.Resolve<ILoggerFactory>().Create(GetType().FullName); }
private void AcceptDone(AsyncSocket cliCon) { cliCon.m_addr = m_addr; cliCon.Address.IP = ((IPEndPoint)cliCon.m_sock.RemoteEndPoint).Address; cliCon.State = SocketState.Connected; cliCon.m_stream = new NetworkStream(cliCon.m_sock); cliCon.m_server = true; cliCon.LocalCertificate = m_cert; cliCon.RequireClientCert = m_requireClientCert; ISocketEventListener l = m_listener.GetListener(cliCon); if (l == null) { // if the listener returns null, close the socket and // quit, instead of asserting. cliCon.m_sock.Close(); RequestAccept(); return; } cliCon.m_listener = l; try { if (m_watcher != null) { m_watcher.RegisterSocket(cliCon); } } catch (InvalidOperationException) { // m_watcher out of slots. cliCon.AsyncClose(); // don't set state // they really don't need this error, we don't think. // Error(e); // tell the watcher that when it gets its act together, // we'd appreciate it if it would restart the RequestAccept(). m_watcher.PendingAccept(this); return; } if (m_secureProtocol != SslProtocols.None) { cliCon.StartTLS(); } if (l.OnAccept(cliCon)) { RequestAccept(); } }
public SocketRemotingServer(string name, SocketSetting socketSetting, ISocketEventListener socketEventListener = null) { _serverSocket = new ServerSocket(socketEventListener); _requestHandlerDict = new Dictionary <int, IRequestHandler>(); _logger = ObjectContainer.Resolve <ILoggerFactory>() .Create(name ?? GetType() .Name); _serverSocket.Bind(socketSetting.Address, socketSetting.Port) .Listen(socketSetting.Backlog); }
public ServerSocket(ISocketEventListener socketEventListener) { _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); _socketEventListener = socketEventListener; _socketService = new SocketService(socketEventListener); _newClientSocketSignal = new ManualResetEvent(false); _logger = ObjectContainer.Resolve <ILoggerFactory>() .Create(GetType() .FullName); }
public ServerSocket(ISocketEventListener socketEventListener) { _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); _clientSocketDict = new ConcurrentDictionary<string, SocketInfo>(); _socketEventListener = socketEventListener; _socketService = new SocketService(NotifySocketReceiveException); _newClientSocketSignal = new ManualResetEvent(false); _scheduleService = ObjectContainer.Resolve<IScheduleService>(); _logger = ObjectContainer.Resolve<ILoggerFactory>().Create(GetType().Name); _running = false; }
/// <summary> /// Called from SocketWatcher. /// </summary> /// <param name="w"></param> /// <param name="listener">The listener for this socket</param> /// <param name="SSL">Do SSL3 and TLS1 on startup (call /// StartTLS later if this is false, and TLS only is needed /// later)</param> /// <param name="synch">Synchronous operation</param> public AsyncSocket(SocketWatcher w, ISocketEventListener listener, bool SSL, bool synch) : base(listener) { m_watcher = w; m_synch = synch; if (SSL) { m_secureProtocol = SSLProtocols; } }
public SocketRemotingClient(string address, int port, ISocketEventListener socketEventListener = null) { _lockObject1 = new object(); _lockObject2 = new object(); _address = address; _port = port; _socketEventListener = socketEventListener; _clientSocket = new ClientSocket(new RemotingClientSocketEventListener(this)); _responseFutureDict = new ConcurrentDictionary <long, ResponseFuture>(); _messageQueue = new BlockingCollection <byte[]>(new ConcurrentQueue <byte[]>()); _scheduleService = ObjectContainer.Resolve <IScheduleService>(); _worker = new Worker("SocketRemotingClient.HandleMessage", HandleMessage); _logger = ObjectContainer.Resolve <ILoggerFactory>() .Create(GetType() .FullName); }
/// <summary> /// Create a socket that is listening for inbound connections. /// </summary> /// <param name="listener">Where to send notifications</param> /// <param name="addr">Address to connect to</param> /// <param name="backlog">The maximum length of the queue of pending connections</param> /// <param name="SSL">Do SSL3/TLS1 on connect</param> /// <returns>A socket that is ready for calling RequestAccept()</returns> public AsyncSocket CreateListenSocket(ISocketEventListener listener, Address addr, int backlog, bool SSL) { //Debug.Assert(m_maxSocks > 1); AsyncSocket result = new AsyncSocket(this, listener, SSL, m_synch); if (SSL) { result.LocalCertificate = m_cert; result.RequireClientCert = m_requireClientCert; } result.Accept(addr, backlog); return(result); }
/// <summary> /// Create an outbound socket. /// </summary> /// <param name="listener">Where to send notifications</param> /// <param name="addr">Address to connect to</param> /// <param name="SSL">Do SSL3/TLS1 on startup</param> /// <param name="hostId">The logical name of the host to connect to, for SSL/TLS purposes.</param> /// <returns>Socket that is in the process of connecting</returns> public AsyncSocket CreateConnectSocket(ISocketEventListener listener, Address addr, bool SSL, string hostId) { AsyncSocket result; // Create the socket: result = new AsyncSocket(this, listener, SSL, m_synch); if (SSL) { result.LocalCertificate = m_cert; } // Start the connect process: result.Connect(addr, hostId); return(result); }
/// <summary> /// Create a socket that is listening for inbound connections, with no SSL/TLS. /// </summary> /// <param name="listener">Where to send notifications</param> /// <param name="addr">Address to connect to</param> /// <returns>A socket that is ready for calling RequestAccept()</returns> public AsyncSocket CreateListenSocket(ISocketEventListener listener, Address addr) { return(CreateListenSocket(listener, addr, 5, false)); }
/// <summary> /// Create a socket that is listening for inbound connections. /// </summary> /// <param name="listener">Where to send notifications</param> /// <param name="addr">Address to connect to</param> /// <param name="backlog">The maximum length of the queue of pending connections</param> /// <param name="SSL">Do SSL3/TLS1 on connect</param> /// <returns>A socket that is ready for calling RequestAccept()</returns> public AsyncSocket CreateListenSocket(ISocketEventListener listener, Address addr, int backlog, bool SSL) { //Debug.Assert(m_maxSocks > 1); AsyncSocket result = new AsyncSocket(this, listener, SSL, m_synch); if (SSL) { result.LocalCertificate = m_cert; result.RequireClientCert = m_requireClientCert; } result.Accept(addr, backlog); return result; }
/// <summary> /// Create an instance /// </summary> /// <param name="listener"></param> public XEP124Socket(ISocketEventListener listener) : base(listener) { }
public ClientSocket(ISocketEventListener socketEventListener) { _socketService = new SocketService(socketEventListener); _logger = ObjectContainer.Resolve<ILoggerFactory>().Create(GetType().FullName); }
/// <summary> /// Construct a BaseSocket. /// </summary> /// <param name="listener"></param> protected BaseSocket(ISocketEventListener listener) { Debug.Assert(listener != null); m_listener = listener; }
/// <summary> /// Called from SocketWatcher. /// </summary> /// <param name="w"></param> /// <param name="listener">The listener for this socket</param> /// <param name="SSL">Do SSL3 and TLS1 on startup (call /// StartTLS later if this is false, and TLS only is needed /// later)</param> /// <param name="synch">Synchronous operation</param> public AsyncSocket(SocketWatcher w, ISocketEventListener listener, bool SSL, bool synch) : base(listener) { m_watcher = w; m_synch = synch; if (SSL) m_secureProtocol = SSLProtocols; }
/// <summary> /// Create an instance /// </summary> /// <param name="listener"></param> public XEP25Socket(ISocketEventListener listener) { Debug.Assert(listener != null); m_listener = listener; }
/// <summary> /// Create an outbound socket. /// </summary> /// <param name="listener">Where to send notifications</param> /// <param name="addr">Address to connect to</param> /// <param name="SSL">Do SSL3/TLS1 on startup</param> /// <param name="hostId">The logical name of the host to connect to, for SSL/TLS purposes.</param> /// <returns>Socket that is in the process of connecting</returns> public AsyncSocket CreateConnectSocket(ISocketEventListener listener, Address addr, bool SSL, string hostId) { AsyncSocket result; // Create the socket: result = new AsyncSocket(this, listener, SSL, m_synch); if (SSL) result.LocalCertificate = m_cert; // Start the connect process: result.Connect(addr, hostId); return result; }
/// <summary> /// Create an outbound socket. /// </summary> /// <param name="listener">Where to send notifications</param> /// <param name="addr">Address to connect to</param> /// <returns>Socket that is in the process of connecting</returns> public AsyncSocket CreateConnectSocket(ISocketEventListener listener, Address addr) { return CreateConnectSocket(listener, addr, false, null); }
/// <summary> /// Create a socket that is listening for inbound connections, with no SSL/TLS. /// </summary> /// <param name="listener">Where to send notifications</param> /// <param name="addr">Address to connect to</param> /// <param name="backlog">The maximum length of the queue of pending connections</param> /// <returns>A socket that is ready for calling RequestAccept()</returns> public AsyncSocket CreateListenSocket(ISocketEventListener listener, Address addr, int backlog) { return CreateListenSocket(listener, addr, backlog, false); }
/// <summary> /// Create a socket that is listening for inbound connections, with no SSL/TLS. /// </summary> /// <param name="listener">Where to send notifications</param> /// <param name="addr">Address to connect to</param> /// <returns>A socket that is ready for calling RequestAccept()</returns> public AsyncSocket CreateListenSocket(ISocketEventListener listener, Address addr) { return CreateListenSocket(listener, addr, 5, false); }
/// <summary> /// Create a socket that is listening for inbound connections. /// </summary> /// <param name="listener">Where to send notifications</param> /// <param name="addr">Address to connect to</param> /// <param name="SSL">Do SSL3/TLS1 on connect</param> /// <returns>A socket that is ready for calling RequestAccept()</returns> public AsyncSocket CreateListenSocket(ISocketEventListener listener, Address addr, bool SSL) { return CreateListenSocket(listener, addr, 5, SSL); }
/// <summary> /// Create a socket that is listening for inbound connections, with no SSL/TLS. /// </summary> /// <param name="listener">Where to send notifications</param> /// <param name="addr">Address to connect to</param> /// <param name="backlog">The maximum length of the queue of pending connections</param> /// <returns>A socket that is ready for calling RequestAccept()</returns> public AsyncSocket CreateListenSocket(ISocketEventListener listener, Address addr, int backlog) { return(CreateListenSocket(listener, addr, backlog, false)); }
/// <summary> /// Create an outbound socket. /// </summary> /// <param name="listener">Where to send notifications</param> /// <param name="addr">Address to connect to</param> /// <returns>Socket that is in the process of connecting</returns> public AsyncSocket CreateConnectSocket(ISocketEventListener listener, Address addr) { return(CreateConnectSocket(listener, addr, false, null)); }
/// <summary> /// Wrap an existing socket event listener with a Socks5 proxy. Make SURE to set Socket after this. /// </summary> /// <param name="chain">Event listener to pass events through to.</param> public Socks5Proxy(ISocketEventListener chain) : base(chain) { }
/// <summary> /// Called from SocketWatcher. /// </summary> /// <param name="w"></param> /// <param name="listener">The listener for this socket</param> public AsyncSocket(SocketWatcher w, ISocketEventListener listener) : base(listener) { m_watcher = w; }
/// <summary> /// Wrap an existing socket event listener with a proxy. Make SURE to set Socket after this. /// </summary> /// <param name="chain">Event listener to pass events through to.</param> public ProxySocket(ISocketEventListener chain) : base(chain) { Password = null; Username = null; }
public void SetSocketEventListener(ISocketEventListener listener) { eventListener = listener; }
/// <summary> /// Create an instance /// </summary> /// <param name="listener"></param> public XEP124Socket(ISocketEventListener listener) : base(listener) { RemoteCertificate = null; StartStream = false; }
/// <summary> /// Wrap an existing socket event listener with a ShttpProxy proxy. Make SURE to set Socket after this. /// </summary> /// <param name="chain">Event listener to pass events through to.</param> public ShttpProxy(ISocketEventListener chain) : base(chain) { }
/// <summary> /// Create a socket that is listening for inbound connections. /// </summary> /// <param name="listener">Where to send notifications</param> /// <param name="addr">Address to connect to</param> /// <param name="SSL">Do SSL3/TLS1 on connect</param> /// <returns>A socket that is ready for calling RequestAccept()</returns> public AsyncSocket CreateListenSocket(ISocketEventListener listener, Address addr, bool SSL) { return(CreateListenSocket(listener, addr, 5, SSL)); }
/// <summary> /// Wrap an existing socket event listener with a proxy. Make SURE to set Socket after this. /// </summary> /// <param name="chain">Event listener to pass events through to.</param> public ProxySocket(ISocketEventListener chain) : base(chain) { }
/// <summary> /// Create a socket. This starts a thread for background processing, but the thread is mostly paused /// waiting for new requests. /// </summary> public HttpSocket(ISocketEventListener listener) : base(listener) { }