Connect() public method

public Connect ( ) : void
return void
Example #1
0
        Connection CreateConnection(string host, int port, bool useSsl)
        {
            Connection connection;

            var key = string.Format("{0}:{1}", host, port);
            if(connectionPool.ContainsKey(key)) {
                connection = connectionPool[key];
                connectionPool.Remove(key);
                return connection;
            }

            connection = new Connection () { host = host, port = port };
            //Debug.Log(host);
            connection.Connect ();

            if (useSsl) {

                connection.stream = new SslStream (connection.client.GetStream (), false, ValidateServerCertificate);
                var ssl = connection.stream as SslStream;
                ssl.AuthenticateAsClient (uri.Host);

            } else {

                connection.stream = connection.client.GetStream ();
            }
            return connection;
        }