private static void onAccept(IAsyncResult asyncResult) { EndPointListener asyncState = (EndPointListener)asyncResult.AsyncState; Socket socket = null; try { socket = asyncState._socket.EndAccept(asyncResult); } catch (SocketException socketException) { } catch (ObjectDisposedException objectDisposedException) { return; } try { asyncState._socket.BeginAccept(new AsyncCallback(EndPointListener.onAccept), asyncState); } catch { if (socket != null) { socket.Close(); } return; } if (socket != null) { EndPointListener.processAccepted(socket, asyncState); } }