Stream Functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,
I have been trying to get the stream functions to work in PHP.  While
undoubtedly my problems are due to ignorance I'd appreciate anything
helpful anyone would care to say that might alleviate that ignorance.
Basically, I have just been trying to get the examples given in the
manual to work for the "unix domain".  I created the two files below
and hit them with my browser.
servertest.php
--------------
<?php
$socket = stream_socket_server("unix://testsock", $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);
}
?>
This appears to be working.  It creates the socket file in the file
system.  Then after a long delay, which I presume is waiting for a
client request, it returns the following.
Warning: stream_socket_accept() [function.stream-socket-accept]:
accept failed: Operation timed out in
/usr/local/www/data/servertest.php on line 6 Afterward the socket file is left on the file system.
socktest.php
------------
<?php
$fp = stream_socket_client("unix://testsock", $errno, $errstr);
if (!$fp) {
  echo "ERROR: $errno - $errstr<br />\n";
} else {
  fwrite($fp, "\n");
  echo fread($fp, 26);
  fclose($fp);
}
?>
Running this while the server is waiting (or after it has given
up) produces the following.
Warning: stream_socket_client() [function.stream-socket-client]:
unable to connect to unix://testsock (Connection refused) in
/usr/local/www/data/socktest.php on line 2
ERROR: 61 - Connection refused
If the socket is removed the message changes to "file not found"
and if the permissions are changed the message changes to "permission
denied".  So the program seems to be finding the socket and have
permission to access it. Can anyone suggest why the connection might be refused? Best, Craig

------------------------------------------------------
-     Virtual Phonecards - Instant Pin by Email      -
-           Large Selection - Great Rates            -
-     http://speedypin.com/?aff=743&co_branded=1     -
------------------------------------------------------

**************************************
*                                    *
*          Craig Spencer             *
*      ccspencer@xxxxxxxxxxxx        *
*                                    *
**************************************

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux