private Packet ReceivePacket() { byte[] bytes = new byte[PacketHeader.SIZE_IN_BYTES]; socket.Receive(bytes, 0, bytes.Length, SocketFlags.None); PacketHeader header = PacketSerializer.deserializeHeader(bytes); byte[] payload = new byte[header.GetLength()]; socket.Receive(payload, 0, payload.Length, SocketFlags.None); return(new Packet(header, payload)); }
public void SendPacket(Packet packet) { byte[] bytes = PacketSerializer.serialize(packet); socket.Send(bytes, bytes.Length, SocketFlags.None); }