Home » » stream_socket_enable_crypto

stream_socket_enable_crypto

Written By 1 on Tuesday, October 2, 2012 | 9:09 AM

mixed stream_socket_enable_crypto ( resource $stream , bool $enable [, int $crypto_type [, resource $session_stream ]] )

Turns encryption on/off on an already connected socket


<?php
$fp 
stream_socket_client("tcp://myproto.example.com:31337"$errno$errstr30);
if (!
$fp) {
    die(
"Unable to connect: $errstr ($errno)");
}

/* Turn on encryption for login phase */
stream_socket_enable_crypto($fptrueSTREAM_CRYPTO_METHOD_SSLv23_CLIENT);
fwrite($fp"USER god\r\n");
fwrite($fp"PASS secret\r\n");

/* Turn off encryption for the rest */
stream_socket_enable_crypto($fpfalse);

while (
$motd fgets($fp)) {
    echo 
$motd;
}

fclose($fp);
?>


0 Comment:

Post a Comment