예제 #1
0
 private void SendCallback(IAsyncResult ar)
 {
     try
     {
         var socket = ar.AsyncState as System.Net.Sockets.Socket;
         int length = 0;
         length = socket.EndSend(ar);
         if (length > 0)
         {
             byte[] data = SendBuffer.ReadFromHead(length);
             SendBytesEvent(data);
             int remain = SendBuffer.Index;
             if (remain > 0)
             {
                 SendBytes(SendBuffer.Buffer, 0, SendBuffer.Index);
             }
         }
         else
         {
             DisconnectedEvent();
         }
     }
     catch (Exception e)
     {
         ExceptionEvent(e);
     }
 }