NetWrok.HTTP.Request.CreateConnection C# (CSharp) Method

CreateConnection() private method

private CreateConnection ( string host, int port, bool useSsl ) : Connection
host string
port int
useSsl bool
return Connection
        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;
        }