Exemplo n.º 1
0
        private void ConnectCallBack(IAsyncResult ar)
        {
            ClientInfo info = ar.AsyncState as ClientInfo;

            if (info == null)
            {
                return;
            }
            try
            {
                info.socket.EndConnect(ar);
                AddClientFun?.Invoke(info);
                int length = info.socket.Client.Send(Encoding.UTF8.GetBytes("client test message"));
                info.nsend += (UInt64)length;
                info.socket.Client.BeginReceive(info.data, 0, 65535, 0, ReadCallBack, info);
            }
            catch (Exception ex)
            {
                return;
            }
        }
Exemplo n.º 2
0
 private void OnAddClient(SocketConnection sender)
 {
     AddClient?.Invoke(sender);
 }