Connect() public method

Connects the client to a remote TCP host using the specified IP address and port number.
The parameter is a null reference (Nothing in Visual Basic). is less than MinPort -or- is greater than MaxPort. An operating system error occurs while accessing the Socket. The has been closed. The security negotiation failed.
public Connect ( IPAddress address, int port ) : void
address System.Net.IPAddress The IP address of the host to which you intend to connect.
port int The port number to which you intend to connect.
return void
コード例 #1
0
 /// <summary><see cref="Ch.Elca.Iiop.IClientTranport.OpenConnection/></summary>
 public void OpenConnection() {
     if (IsConnectionOpen()) {
         return; // already open
     }
     m_socket = new SecureTcpClient(m_options);
     if (m_targetHostIp != null) {
         m_socket.Connect(m_targetHostIp, m_port);
     } else if (m_targetHost != null) {
         m_socket.Connect(m_targetHost, m_port);
     } else {
         throw new INTERNAL(547, CompletionStatus.Completed_No);
     }
     m_socket.NoDelay = true; // send immediately; (TODO: what is better here?)
     m_socket.ReceiveTimeout = m_receiveTimeOut;
     m_socket.SendTimeout = m_sendTimeOut;
     m_stream = m_socket.GetStream();
 }
コード例 #2
0
ファイル: Connection.cs プロジェクト: Jakosa/alaris
        private void ConnectClient( SecureProtocol protocol )
        {
            lock ( this )
            {
                if( connected )
                {
                    throw new Exception("Connection with IRC server already opened.");
                }
                Debug.WriteLineIf( Rfc2812Util.IrcTrace.TraceInfo,"[" + Thread.CurrentThread.Name +"] Connection::Connect()");

                    SecurityOptions options = new SecurityOptions( protocol );
                    options.Certificate = null;
                    options.Entity = ConnectionEnd.Client;
                    options.VerificationType = CredentialVerification.None;
                    options.Flags = SecurityFlags.Default;
                    options.AllowedAlgorithms = SslAlgorithms.SECURE_CIPHERS;
                    client = new SecureTcpClient( options );
                    client.Connect( connectionArgs.Hostname, connectionArgs.Port );

                connected = true;
                writer = new StreamWriter( client.GetStream(), TextEncoding );
                writer.AutoFlush = true;
                reader = new StreamReader(  client.GetStream(), TextEncoding );
                socketListenThread = new Thread(new ThreadStart( ReceiveIRCMessages ) );
                socketListenThread.Name = Name;
                socketListenThread.Start();
                sender.RegisterConnection( connectionArgs );
            }
        }