public Listener(IPEndPoint ipep) { m_Accepted = new Queue <Socket>(); m_AcceptedSyncRoot = ((ICollection)m_Accepted).SyncRoot; m_Listener = Bind(ipep); if (m_Listener == null) { return; } DisplayListener(); _PingListener = new PingListener(ipep); m_OnAccept = OnAccept; try { IAsyncResult res = m_Listener.BeginAccept(m_OnAccept, m_Listener); } catch (SocketException ex) { NetState.TraceException(ex); } catch (ObjectDisposedException) { } }
public Listener(IPEndPoint ipep) { m_Accepted = new Queue <Socket>(); m_AcceptedSyncRoot = ((ICollection)m_Accepted).SyncRoot; m_Listener = Bind(ipep); if (m_Listener == null) { return; } DisplayListener(); _PingListener = new PingListener(ipep); #if NewAsyncSockets m_EventArgs = new SocketAsyncEventArgs(); m_EventArgs.Completed += new EventHandler <SocketAsyncEventArgs>(Accept_Completion); Accept_Start(); #else m_OnAccept = OnAccept; try { IAsyncResult res = m_Listener.BeginAccept(m_OnAccept, m_Listener); } catch (SocketException ex) { NetState.TraceException(ex); } catch (ObjectDisposedException) { } #endif }
public void Dispose() { Socket socket = Interlocked.Exchange(ref m_Listener, null); if (socket != null) { socket.Close(); } if (_PingListener == null) { return; } _PingListener.Dispose(); _PingListener = null; }