Bug #14806 Updated: server RECV strange if using PHP clients
| From: | jason@php.net | Date: | Mon, 01 Jul 2002 19:55:53 +0000 |
| Subject: | Bug #14806 Updated: server RECV strange if using PHP clients | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-12707@lists.php.net to get a copy of this message | ||
ID: 14806
Updated by: jason@php.net
Reported By: wolfgang.sprick@tlc.de
-Status: Open
+Status: Bogus
Bug Type: Sockets related
Operating System: W2K
PHP Version: 4.1.0
New Comment:
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php
If you can provide more information, feel free to add it
to this bug and change the status back to "Open".
Thank you for your interest in PHP.
I breifly looked at basic-server.cpp and there are some problems, as it
is written as just an example. We need the smallest possible script
that highlights the problem (to the function that produces the problem
if possible). You may want
to try posting a bug report demonstrating the problem using
a known good server, like connecting to a webserver.
Previous Comments:
------------------------------------------------------------------------
[2002-01-02 13:03:05] wolfgang.sprick@tlc.de
we've got a serious problem that we couldn't fix within a week even
after trying several options. So we very much appreciate ANY help.
We use PHP 4.1.0 on Windows 2000 server under IIS.
Situation: we are running socket-based servers that follow the
implementation recommendations found at http://tangentsoft.net/wskfaq/.
The problems encountered can be reproduced by using the "BasisServer"
provided at
http://tangentsoft.net/wskfaq/examples/basics/basic-client.html.
Test1.
We use the fokkowing PHP-Script. Thereby we use the native
socket-functions introduced in PHP 4.1.0.
<?
$port = 2222;
$string = "P RegioTicket/Haltestellensuche@R 0@N Frankfurt@A 15@";
$socket = socket_create (AF_INET, SOCK_STREAM, 0);
if ($socket < 0)
{
echo "socket_create() failed: reason: ";
}
else
{
"socket_create() successful: ";
}
$ip = gethostbyname ('172.24.79.232');
echo " Attempting to connect to '$ip' on port '$port'...";
$result = socket_connect ($socket, $ip, $port);
if ($result < 0)
{
echo "socket_connect() failed.\nReason: ($result) " .
socket_strerror($result) . "\n";
}
else
{
echo " OK.\n";
}
$length = strlen($string);
echo "<br>Variable $" . $string . "$<BR>";
$retcodew = socket_write ($socket, $string, $length);
$retcoder = socket_read ($socket, $var, 10);
echo "<br>Variable $" . $var . "$<BR>";
echo "return Code Write :" . $retcodew . "<br>";
echo "Return Code Read :" . $retcoder ;
?>
To follow the example debug the BasicServer.exe (basic-server.cpp) or
just believe me <g>.
The server waits within ACCEPT. When the client sends data it RECEIVES
this data and SENDS it back as an echo. It cycles throught the rest of
the loop, ending in another RECEIVE. This RECEIVE returns "-1", which
is recognized as an socket error, finally leading into closing down the
server. Unwanted result.
Test2.
We use the following PHP-script. Thereby we use the classic style with
fsockopen, fputs, fgets, fsockclose.
<?php
$anfrage = "P RegioTicket/Haltestellensuche@";
$anfrage .= "R 0@";
$anfrage .= "N Frankfurt@";
$anfrage .= "A 15@";
echo "$anfrage <br>";
$fp = fsockopen("172.24.79.232", 2222, &$errno, &$errstr, 10);
if(!$fp)
{
$err = "error: $errstr ($errno)<br>";
return $err;
}
else
{
$n = strlen($anfrage); // size of buffer for request
//$str = sprintf("%08d%s", $n, $anfrage);
fputs($fp, $anfrage);
echo "test nach puts()";
$result = fgets($fp, 128);
//get_selection($fp, $select);
//socket_shutdown($fp, 1);
fclose($fp);
return $result;
}
?>
The server waits within ACCEPT. When the client sends data it RECEIVES
this data and SENDS it back as an echo. It cycles throught the rest of
the loop, ending in another RECEIVE. This RECEIVE waits indefinitely
until some timeout occurs. Unwanted result, the server is blocked.
Test3.
We use one of our good old REXX scripts and rxsock.dll.
The server waits within ACCEPT. When the client sends data it RECEIVES
this data and SENDS it back as an echo. It cycles throught the rest of
the loop, ending in another RECEIVE. This RECEIVE returns "0" which
indicates that no more data is available, the server closes the
connection, recycles itself into the ACCEPT statement again and waits
for the next connection request. We consider this to be the expected
result, being comaptible to our own C++-clients and the examples we
found in the Internet.
So our question is, why the results are different when using PHP. Maybe
we just need to know how to inplement that in a better way using PHP.
But as we already spent some considerable time with it, we think, that
the inplementation within PHP (both) might need some improvement. But
maybe PHP just needs server that follow some rules of a protocol. If
so, where can we find specifications for this?
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=14806&edit=1