Ejemplo n.º 1
0
        private void InitializeListener()
        {
            try
            {
                SocketHandler sHandler = new SocketHandler()
                {
                    TS3SRV_SOCKET = TS3SRV_WEBLIST_SOCKET,
                };

                TS3SRV_WEBLIST_SOCKET.BeginReceive(sHandler.TS3SRV_SOCKET_BUFFER, 0, sHandler.TS3SRV_SOCKET_BUFFER.Length, SocketFlags.None, Listener, sHandler);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Ejemplo n.º 2
0
        private void Listener(IAsyncResult aResult)
        {
            SocketHandler sHandler = (SocketHandler)aResult.AsyncState;
            int           recvLen  = sHandler.TS3SRV_SOCKET.EndReceive(aResult);

            InitializeListener();
            if (recvLen > 0 && recvLen <= sHandler.TS3SRV_SOCKET_BUFFER.Length)
            {
                try
                {
                    byte[] actualDataBytes = new byte[recvLen];
                    Array.Copy(sHandler.TS3SRV_SOCKET_BUFFER, 0, actualDataBytes, 0, recvLen);
                    HandleIncoming(new IncomingPayloadHandler(actualDataBytes));
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }
            }
        }