Ejemplo n.º 1
0
 ///-------------------------------------------------------------------------------------------------
 /// <summary>   Converts the given TCP response. </summary>
 ///
 /// <remarks>   Justin, 7/11/2015. </remarks>
 ///
 /// <param name="tcpResponse">  The TCP response. </param>
 ///
 /// <returns>   A list of. </returns>
 ///-------------------------------------------------------------------------------------------------
 public ITcpListenerResponse Convert(ITcpResponse tcpResponse)
 {
     ITcpListenerResponse result = new TcpListenerResponse();
     result.State = tcpResponse.State;
     result.AsyncResult = tcpResponse.AsyncResult;
     result.Result = tcpResponse.Result;
     result.Listener = tcpResponse.AsyncResult.AsyncState as TcpListener;
     return result;
 }
Ejemplo n.º 2
0
        /// -------------------------------------------------------------------------------------------------
        ///  <summary>   Begins accept TCP client. </summary>
        /// 
        ///  <remarks>   Justin, 7/11/2015. </remarks>
        /// <param name="byteArrLength">    Length of the byte array. </param>
        /// <param name="form1">            The first form. </param>
        /// <returns>   A TcpState. </returns>
        /// -------------------------------------------------------------------------------------------------
        public ITcpResponse BeginAcceptTcpClient(long byteArrLength, IForm form1)
        {
            //async operation to accept incoming requests
            ITcpResponse response = new TcpListenerResponse { Result = string.Empty, State = TcpState.NotReady };

            response = AcceptTcpClient(byteArrLength, form1, response);

            return response;
        }
Ejemplo n.º 3
0
        ///-------------------------------------------------------------------------------------------------
        /// <summary>   Converts the given iar. </summary>
        ///
        /// <remarks>   Justin, 7/11/2015. </remarks>
        ///
        /// <param name="iar">  The iar. </param>
        ///
        /// <returns>   A TcpResponse. </returns>
        ///-------------------------------------------------------------------------------------------------
        public ITcpListenerResponse Convert(IAsyncResult iar)
        {
            var response = new TcpListenerResponse();

            var tcpl = iar.AsyncState as TcpListener;

            if (tcpl == null)
            {
                response.Result = "there was an issue casting the TCP listener";

                response.State = TcpState.Failed;
            }

            response.AsyncResult = iar;

            response.Listener = tcpl;

            response.State = TcpState.Success;

            return response;
        }