Ejemplo n.º 1
0
        protected override void SendAsync(Threads.Result result, BufferPool.Buffer data, bool dispose_buffer = true)
        {
            try
            {
                if (Connected())
                {
                    Converter32 c = new Converter32(data.Size);

                    writeBuffer.Data[0] = c.Byte1;
                    writeBuffer.Data[1] = c.Byte2;
                    writeBuffer.Data[2] = c.Byte3;
                    writeBuffer.Data[3] = c.Byte4;

                    BeginSend(writeBuffer.Data, writeBuffer.Data.Length, FinalizeSendLength, new SendState(result, data, dispose_buffer));
                }
                else
                {
                    throw new ArgumentNullException("client", "The connection is not opened.");
                }
            }
            catch (Exception e)
            {
                result.Complete(e);
            }
        }
Ejemplo n.º 2
0
        protected override void SendAsync(Threads.Result result, byte[] data)
        {
            try
            {
                if (client != null)
                {
                    Converter32 c = new Converter32(data.Length);

                    writeBuffer[0] = c.Byte1;
                    writeBuffer[1] = c.Byte2;
                    writeBuffer[2] = c.Byte3;
                    writeBuffer[3] = c.Byte4;

                    stream.BeginWrite(writeBuffer, 0, writeBuffer.Length, FinalizeSendLength, new SendState {
                        result = result, data = data
                    });
                }
                else
                {
                    throw new ArgumentNullException("client", "The connection tcpClient is not defined.");
                }
            }
            catch (Exception e)
            {
                result.Complete(e);
            }
        }
Ejemplo n.º 3
0
 protected override void SendAsync(Threads.Result result, byte[] data)
 {
     try
     {
         if (client != null)
         {
             client.BeginSend(data, data.Length, FinalizeSend, new SendState {
                 result = result, data = data
             });
         }
         else
         {
             throw new ArgumentNullException("client", "The connection UdpClient is not defined.");
         }
     }
     catch (Exception e)
     {
         result.Complete(e);
     }
 }