Created
March 30, 2016 15:16
-
-
Save adamjakab/82756e24c69119cedddcc64725632e48 to your computer and use it in GitHub Desktop.
stream_socket_client tests for palin and ssl resources
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(E_ALL); | |
ini_set("display_errors",1 ); | |
$socket_context = stream_context_create([]); | |
$timeout = 30; | |
$errno = 0; | |
$errstr = ''; | |
//PLAIN | |
$host1 = 'mail.staff.mekit.it'; | |
$port1 = 25; | |
//SSL | |
$host2 = 'ssl://' . $host1; | |
$port2 = 993; | |
echo "<hr/><h1>HOST1 - $host1</h1>"; | |
$conn1 = stream_socket_client( | |
$host1 . ":" . $port1, | |
$errno, | |
$errstr, | |
$timeout, | |
STREAM_CLIENT_CONNECT, | |
$socket_context | |
); | |
echo is_resource($conn1) ? "CONN-OK" : "CONN-NOPE! "; | |
echo "<hr/><h1>HOST2 - $host2</h1>"; | |
$conn2 = stream_socket_client( | |
$host2 . ":" . $port2, | |
$errno, | |
$errstr, | |
$timeout, | |
STREAM_CLIENT_CONNECT, | |
$socket_context | |
); | |
echo is_resource($conn2) ? "CONN-OK" : "CONN-NOPE! "; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment