Example #1
0
 protected internal override void NetworkStreamAccept()
 {
     try
     {
         AsyncAcceptStatusObject state = new AsyncAcceptStatusObject(base.Socket);
         base.Socket.BeginAccept(new AsyncCallback(AcceptCallback), state);
         WaitForEvent(state.waitEvent, TimeOut);
         CheckAsyncException(state);
         base.Socket          = state.AcceptedSocket;
         base.Socket.Blocking = true;
     }
     catch (SocketException exception)
     {
         throw new SocketError(exception.Message, exception.ErrorCode, exception);
     }
 }
Example #2
0
        private void AcceptCallback(IAsyncResult ar)
        {
            AsyncAcceptStatusObject asyncState = (AsyncAcceptStatusObject)ar.AsyncState;

            try
            {
                asyncState.AcceptedSocket = asyncState.socket.EndAccept(ar);
            }
            catch (Exception exception)
            {
                asyncState.exception = exception;
            }
            finally
            {
                asyncState.waitEvent.Set();
            }
        }