Created
July 5, 2015 11:47
-
-
Save velikanov/45e089118964721bffb8 to your computer and use it in GitHub Desktop.
socket_read hang problem
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
if (false === ($socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP))) { | |
$errorMessages[] = 'socket_create'; | |
$errorMessages[] = socket_strerror(socket_last_error()); | |
$errorCode = 1; | |
} else { | |
$container = $this->getContainer(); | |
if (false === (socket_connect($socket, '174.37.69.2', '443'))) { | |
$errorMessages[] = 'socket_connect'; | |
$errorMessages[] = socket_strerror(socket_last_error()); | |
$errorCode = 2; | |
} else { | |
if (false === socket_write($socket, 'WINFO', strlen('WINFO'))) { | |
return false; | |
} else { | |
while ($receivedData = socket_read($socket, 1)) { | |
echo $receivedData; | |
} | |
return $receivedData; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment