Example #1
0
 private static void SendBase(NetworkState data)
 {
     try
     {
         data.Socket.BeginSend(data.Buffer, data.Offset, data.Count, SocketFlags.None, EndSendCallback, data);
     }
     catch
     {
         data.Callback(false, 0, data.State);
         Cache.Put(data);
     }
 }
Example #2
0
 private static void ReceiveBase(NetworkState data)
 {
     try
     {
         data.Socket.BeginReceive(data.Buffer, data.Offset, data.Remaining, SocketFlags.None, EndReceiveCallback,
                                  data);
     }
     catch
     {
         data.Callback(false, 0, data.State);
         Cache.Put(data);
     }
 }
Example #3
0
        private static async void ReceiveBase(NetworkState data)
        {
            try
            {
                data.BytesTransferred = await data.Socket.ReceiveAsync(new ArraySegment <byte>(data.Buffer, data.Offset, data.Remaining), SocketFlags.None);

                new AsyncResult(EndReceiveCallback, data).Complete();
            }
            catch
            {
                data.Callback(false, 0, data.State);
                Cache.Put(data);
            }
        }