예제 #1
0
        private static void AcceptCallback(IAsyncResult ar)
        {
            var chanelSocket = serverListenerHandler.EndAccept(ar);
            var chanel       = new Chanel(chanelSocket);

            chanelSocket.BeginReceive(chanel.Buffer, 0, Chanel.BufferSize, 0, new AsyncCallback(ReadCallback), chanel);
        }
예제 #2
0
        public int Add(Chanel chanel)
        {
            int id = count;

            chanels.Add(count, chanel);
            count++;

            return(id);
        }
예제 #3
0
        private static void AcceptCallback(IAsyncResult ar)
        {
            allDone.Set();

            var listener     = (Socket)ar.AsyncState;
            var clientSocket = listener.EndAccept(ar);

            var chanel = new Chanel(clientSocket);

            Console.WriteLine("client connected: " + SocketLogger.ChanelInfo(chanel));

            clientSocket.BeginReceive(chanel.Buffer, 0, Chanel.BufferSize, 0, new AsyncCallback(ReadCallback), chanel);
        }
예제 #4
0
        private static void Send(Chanel chanel, object result)
        {
            var data = Serializer.Serialize(result);

            chanel.ChanelHandler.BeginSend(data, 0, data.Length, 0, new AsyncCallback(SendCallback), chanel);
        }