Beispiel #1
0
        protected void SendTlvPacket(byte[] packet)
        {
            try
            {
                var tlvPacket = NetworkTlvPacket.TlvPacketFrom(packet);

                //    Console.WriteLine("PACKET SIZE: " + packet.Length);

                tcpClient?.GetStream().Write(tlvPacket, 0, tlvPacket.Length);
            }
            catch (Exception)
            {
                Close();
                throw;
            }
        }
Beispiel #2
0
        protected IAsyncResult SendTlvPacketAsync(byte[] packet)
        {
            var tlvPacket = NetworkTlvPacket.TlvPacketFrom(packet);

            try
            {
                var networkStream = tcpClient.GetStream();

                WriteDelegate write = networkStream.Write;
                //we DONT use BeginWrite because of buggy mono that sometimes does not Derive this message
                var result = write.BeginInvoke(tlvPacket, 0, tlvPacket.Length, WriteCallback, null);
                return(result);
            }
            catch (Exception)
            {
                Close();
            }

            return(null);
        }