/// <summary>
 /// Send data to client.
 /// </summary>
 /// <param name="bytes">The byte array to be send.</param>
 /// <param name="offset">The position in the data buffer at witch to begin sending.</param>
 /// <param name="length">The number of the bytes to be send.</param>
 public void SendData(byte[] bytes, int offset, int length)
 {
     if (!this.fIsConnected)
     {
         throw new ClientIsDisconnectedException(this);
     }
     fBytesOut             += length;
     fMyListener.fBytesOut += length;
     fLastOugoingPacket     = new OutgoingTCPClientConnectionPacket(this, bytes, offset, length, fLastOugoingPacket);
 }
        public void DisconnectMe()
        {
            if (fActive)
            {
                fActive      = false;
                fIsConnected = false;

                try
                {
                    fConnection.Close();
                }
                catch (Exception ex)
                {
                }

                if (fUseMessageCollector && fMyMessageCollector != null)
                {
                    fMyMessageCollector.Dispose();
                }

                if (fLastIncomingPacket != null)
                {
                    fLastIncomingPacket.Cancel();
                }

                if (fLastOugoingPacket != null)
                {
                    fLastOugoingPacket.Cancel();
                }

                if (fLastMessageCollectorPacket != null)
                {
                    fLastMessageCollectorPacket.Cancel();
                }

                fConnection                 = null;
                fLastIncomingPacket         = null;
                fLastOugoingPacket          = null;
                fLastMessageCollectorPacket = null;
                fMyMessageCollector         = null;

                fMyListener.RemoveClient(fIPAddress);
                fMyListener.MyExtasysTCPServer.OnClientDisconnect(this);
            }
        }
 public OutgoingPacketFailedException(OutgoingTCPClientConnectionPacket packet)
     : base("Outgoing packet failed")
 {
     fPacket = packet;
 }