Exemplo n.º 1
0
        public void SendMessage(string ip, string message)
        {
            LOClientSocket client = this.client_list.Find(((LOClientSocket obj) => {
                return(obj.IP.Equals(ip));
            }));

            client.SendMessage(message, (bool isSended) => {
                this.SendBlock(client, isSended);
            });
        }
Exemplo n.º 2
0
        /// <summary>
        /// 接受一个客户端的链接请求,只要有一个客户端请求,就会回调该函数.
        /// </summary>
        void ServerAccept(System.IAsyncResult ar)
        {
            //将服务器Socket对象转换出来.
            Socket server = ar.AsyncState as Socket;

            //请求结束后在服务器端产生的客户端对象
            //每一个客户端请求,服务器上会产生一个对应的客户端对象
            Socket client = server.EndAccept(ar);

            //创建
            LOClientSocket cs = new LOClientSocket(client);


            this.client_list.Add(cs);

            this.accept_block(cs);

            cs.BeginReceive((string content) => {
                this.ReceiveBlock(cs, content);
            });

            //开始等待接受客户端请求
            server.BeginAccept(new System.AsyncCallback(ServerAccept), server);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 接受一个客户端的链接请求,只要有一个客户端请求,就会回调该函数.
        /// </summary>
        void ServerAccept(System.IAsyncResult ar)
        {
            //将服务器Socket对象转换出来.
            Socket server = ar.AsyncState as Socket;

            //请求结束后在服务器端产生的客户端对象
            //每一个客户端请求,服务器上会产生一个对应的客户端对象
            Socket client = server.EndAccept (ar);

            //创建
            LOClientSocket cs = new LOClientSocket (client);

            this.client_list.Add (cs);

            this.accept_block (cs);

            cs.BeginReceive ((string content) => {
                this.ReceiveBlock(cs,content);
            });

            //开始等待接受客户端请求
            server.BeginAccept(new System.AsyncCallback(ServerAccept),server);
        }