예제 #1
0
        private static bool ReceivePacketVer1(TcpClient client, out RadminPackets.PacketVer1 response)
        {
            bool status = false;
            int  blocklen, datalen;

            response = new RadminPackets.PacketVer1();

            RadminPackets.PacketHeaderVer1 header = new RadminPackets.PacketHeaderVer1();
            RadminPackets.PacketDataVer1   block  = new RadminPackets.PacketDataVer1();

            response.code    = 0;
            response.datalen = 0;
            response.data    = null;

            byte[] buffer = GetBytesFromTcp(client);
            header = ByteTools.ByteArrayToStructure <RadminPackets.PacketHeaderVer1>(buffer);



            return(status);
        }
예제 #2
0
        private static bool SendPacketVer1(TcpClient client, RadminPackets.PacketVer1 packet)
        {
            bool status = false;

            RadminPackets.PacketHeaderVer1 header = new RadminPackets.PacketHeaderVer1();
            RadminPackets.PacketDataVer1   block  = new RadminPackets.PacketDataVer1();

            block.code = packet.code;
            header.one = 1;

            using (var stream = client.GetStream())
            {
                byte[] headerBytes = ByteTools.ToByteArray(header);
                stream.Write(headerBytes, 0, headerBytes.Length);

                byte[] blockBytes = ByteTools.ToByteArray(block);
                stream.Write(blockBytes, 0, blockBytes.Length);

                status = true;
            }

            return(status);
        }