|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-02-10 14:28 UTC] glox at glox dot be
Description:
------------
stream_socket_accept() returns the following error with the example from the manual page:
Warning: stream_socket_accept(): accept failed: Invalid argument in /share/wolfd/serv.php on line 6
I'm running this on freeBSD 5.1 with the latest php snapshot at this moment.
Reproduce code:
---------------
Server:
<?php
$socket = stream_socket_server("udp://0.0.0.0:13", $errno, $errstr, STREAM_SERVER_BIND);
if (!$socket) {
echo "ERROR: $errno - $errstr<br />\n";
} else {
while ($conn = stream_socket_accept($socket)) {
fwrite($conn, date("D M j H:i:s Y\r\n"));
fclose($conn);
}
fclose($socket);
}
?>
Client:
<?php
$sock = stream_socket_client('udp://127.0.0.1:13');
fwrite($sock, "a\n"); //if I don't add this nothing happens
$get = fgets($sock);
echo $get;
fclose($sock);
?>
Expected result:
----------------
The connection to the client should open, it should send the time and close.
Actual result:
--------------
Warning: stream_socket_accept(): accept failed: Invalid argument in /share/wolfd/serv.php on line 6
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 17 14:00:02 2025 UTC |
I had no time to fix this yet, but you should use something like: $srv = stream_socket_server("udp://127.0.0.1:13"); do { $pkt = stream_socket_recvfrom($srv, 1, 0, $peer); stream_socket_sendto($srv, date("D M j H:i:s Y\r\n"), 0, $peer); } while ($pkt !== false);