protected void AcceptConnection(IAsyncResult result) { try { Accepted.Set(); Socket listener, handler; if (result == null || (listener = result.AsyncState as Socket) == null || (handler = listener.EndAccept(result)) == null) { return; } // TODO: Consider making this configurable. const int bufferSize = 1024; // Begin receiving. var state = new TransmissionState(this, bufferSize, handler, ServiceValues.EoF); state.Receive(); } catch (ObjectDisposedException) { // Exit gracefully in the event of a shutdown. } catch (Exception e) { ErrorOut(e); } }