PHP code example of osushi / simple-socket
1. Go to this page and download the library: Download osushi/simple-socket library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
osushi / simple-socket example snippets
$connector = new \SimpleSocket\Connector();
$connector->connectTcp('google.com', 80)->then(function ($conn) {
$conn->write("GET / HTTP/1.1\r\n\Host: google.com\r\n\r\n");
var_dump($conn->read());
/*
string(519) "HTTP/1.1 302 Found
....
</BODY></HTML>"
*/
$conn->close();
});