Bug #2760: Failure to read from Windows sockets
| From: | pjones at ssc dot nmfs dot gov | Date: | Thu, 18 Nov 1999 20:46:00 +0000 |
| Subject: | Bug #2760: Failure to read from Windows sockets | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-12742@lists.php.net to get a copy of this message | ||
From: pjones@ssc.nmfs.gov
Operating system: Mandrake Linux 6.1
PHP version: 3.0.12
PHP Bug Type: Misbehaving function
Bug description: Failure to read from Windows sockets
We have php 3.0.12/apache running on a Mandrake Linux 6.1 server, attempting to communicate with a
socket on a Windows NT 4.0 sp5 machine. Write operations to the socket are successful, but reading
back from the socket always blocks until timeout.
Here's what's supposed to happen:
1. PHP opens a socket to the Windows machine
2. PHP writes a string (a processing instruction to the app on Windows)
3. The app on Windows writes a reply back to PHP
4. PHP reads the reply into a variable, etc etc
Steps 1-3 work correctly. However, php always fails to read back the reply from the Windows
application using any number of approaches, such as:
function doTest(&$command) {
$reply;
$fp = fsockopen("marlin.ssc.nmfs.gov", 6692, &$errno, &$errstr, 30);
if(!$fp) {
return "Error opening socket.";
} else {
fputs($fp,$command);
while ($buffer = fgets($fp, 128)) {
$reply .= $buffer;
}
fclose($fp);
}
return $reply;
}
or replace the fgets with calls to fgetc, or any other piece of file-reading code.
Note the similarity to jisun66@hotmail.com's comment on the fgets manual page online, and the
similarity to bug #2493.
FWIW, reading from the windows socket using a java program works without a hitch, so it does appear
to be a php-specific problem.