Re: Command line socket server and SSL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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;
}


-- 
Greg Donald
Cyberfusion Consulting
http://cyberfusionconsulting.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux