Example #1
0
        public void Connect(IPAddress remoteAddress, int remotePort, int connectionTimeout)
        {
            _remoteAddress = remoteAddress;
            _remotePort = remotePort;
            _timeout = connectionTimeout;

            if (!Connect())
            {
                throw new IOException(string.Format(DongleResource.TcpConnectionError, remoteAddress, remotePort));
            }

            _socket.Blocking = true;
            _tcpClient = new global::System.Net.Sockets.TcpClient { Client = _socket, SendTimeout = connectionTimeout, ReceiveTimeout = connectionTimeout };
        }
Example #2
0
 /// <summary>
 /// Encerra a conexão
 /// </summary>
 private void Disconnect()
 {
     try
     {
         if(_tcpClient != null)
         {
             _tcpClient.Close();
         }
     }
     catch (Exception exception)
     {
         if (OnErrorOcurred != null)
         {
             OnErrorOcurred(_socket, exception);
         }
     }
     _tcpClient = null;
     _socket = null;
 }