Created
August 11, 2020 09:47
-
-
Save FrankSpierings/ac942c43a027f3cb2f6f5b44b0492afc to your computer and use it in GitHub Desktop.
PHP Socket Connect Example Reference
This file contains 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 | |
$host = "ifconfig.co"; | |
$port = 80; | |
$msg = "GET / HTTP/1.1\r\nHost: $host\r\n\r\n"; | |
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); | |
socket_connect($sock, $host, $port); | |
socket_send($sock, $msg, strlen($msg), 0); | |
$result = socket_read($sock, 4096); | |
echo $result; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment