Re: Command line socket server and SSL

From: Date: Wed, 05 Sep 2007 07:00:24 +0000
Subject: Re: Command line socket server and SSL
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-261715@lists.php.net to get a copy of this message
Below you have described a client. I'm talking about a server. That was clear in my original post. -Paul W Greg Donald wrote:
On Tue, 4 Sep 2007, Paul wrote:
Which part do you need help with? The SSL part or the command line or the port or ... ? http://www.php.net/openssl http://www.php.net/sockets
I am familiar with the above links. What I cannot locate is anything that indicates that a cmd line socket program in PHP can do SSL. Can you locate such? Is it in the openssl document somewhere and I missed it?
Whether the script is command line or not has nothing to do with it's ability to connect to a host on a specific port. You just connect to the port the secure socket is located on, usually 443. #!/usr/bin/env php <?php $s = socket_create( AF_INET, SOCK_STREAM, SOL_TCP ); socket_set_nonblock( $s ); socket_connect( $s, "example.com", 443 ); socket_set_block( $s ); switch( socket_select( $r = array( $s ), $w = array( $s ), $f = array( $s ), 5 ) ) {
    case 2:
        echo "[-] Connection Refused\n";
        break;
    case 1:
        echo "[+] Connected\n";
        break;
    case 0:
        echo "[-] Timeout\n";
        break;
}


« previous php.general (#261715) next »