Skip to content

Instantly share code, notes, and snippets.

@yasudacloud
Last active September 3, 2022 03:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yasudacloud/fbf437af9049983cef033d4cefb00ed5 to your computer and use it in GitHub Desktop.
Save yasudacloud/fbf437af9049983cef033d4cefb00ed5 to your computer and use it in GitHub Desktop.
<?php
$timeout = 2000;
$socket = stream_socket_client(
'unix://test.sock',
$errorCode,
$errorMessage,
$timeout,
);
if (!$socket) {
var_dump($errorCode);
var_dump($errorMessage);
throw new Exception('Failed Socket Client');
}
fwrite($socket, "CLIENT MESSAGE\n");
while (!feof($socket)) {
echo fgets($socket, 1024);
}
fclose($socket);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment