예제 #1
0
 //Send packet
 override public void SendPacket(PacketBuffer data)
 {
     byte[] newBuf = new byte[data.GetLength() + 12];
     Array.Copy(BitConverter.GetBytes((UInt32)0xdeadc0de), 0, newBuf, 0, 4);       //Magic number
     Array.Copy(BitConverter.GetBytes((UInt32)12), 0, newBuf, 4, 4);               //Header length
     Array.Copy(BitConverter.GetBytes((UInt32)data.GetLength()), 0, newBuf, 8, 4); //Payload length
     Array.Copy(data.GetData(), 0, newBuf, 12, data.GetLength());                  //Actual payload
     try
     {
         GetSocket().Send(newBuf, 0, data.GetLength() + 12, 0);
     }
     catch (SocketException e)
     {
         Logger.Warn("Socket Exception: " + e.Message);
     }
 }
예제 #2
0
 //Send packet
 virtual public void SendPacket(PacketBuffer data)
 {
     socket.Send(data.GetData(), 0, data.GetLength(), 0);
 }