#23242 [NEW]: socket_read() o linux "stop" with 2 or more users connected...
| From: | david at wups dot net | Date: | Wed, 16 Apr 2003 17:10:32 +0000 |
| Subject: | #23242 [NEW]: socket_read() o linux "stop" with 2 or more users connected... | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-37762@lists.php.net to get a copy of this message | ||
From: david at wups dot net
Operating system: MDK 8.2 / windows xp
PHP version: 4.3.1
PHP Bug Type: Sockets related
Bug description: socket_read() o linux "stop" with 2 or more users connected...
I'm test this script in windows xp (PHP Version 4.3.0)....... but
this script works in windows xp (ph 4.3.0) with 2 or more users
connected......
however, when i try to use this same script on my linux box (mandrake 8.2
php.4.3.1)... and i can't send 2 or more messages without send a some
message in another connection.
(Sorry for my bad English! its powered by http://babelfish.altavista.com/
)
:)
<?php
ob_implicit_flush ();
error_reporting (E_ALL);
$address = '192.168.0.249';
$port = 1433;
if (($sock = socket_create (AF_INET, SOCK_STREAM, 0)) < 0) {
echo "socket_create() failed: reason: " . socket_strerror
(socket_last_error()) . "\n";
exit;
}
if( !(socket_set_nonblock( $sock ) ) ) {
echo "socket_set_nonblock()" . socket_strerror(socket_last_error()) .
"\n";
exit;
}
if (($ret = socket_bind ($sock, $address, $port)) < 0) {
echo "socket_bind() failed: reason: " . socket_strerror
(socket_last_error()) . "\n";
exit;
}
if (($ret = socket_listen ($sock, 5)) < 0) {
echo "socket_listen() failed: reason: " . socket_strerror
(socket_last_error()) . "\n";
exit;
}
$vtSock = Array();
global $vtSock;
$volta = 0;
do {
$msgsock = @socket_accept($sock);
if (is_resource($msgsock)) {
$vtSock[] = $msgsock;
/* Send instructions. */
$msg = "\nWelcome! \n\r.\n\r";
socket_write($msgsock, $msg, strlen($msg));
}
for ($x=0;$x<count($vtSock);$x++) {
$oSock = $vtSock[$x];
if ($oSock != false) {
$buf = @socket_read( $oSock, 2048 );
if (strlen($buf) > 0) {
$talkback = "TELNET [$x] send: '$buf'.\n\r";
socket_write ($oSock, $talkback, strlen ($talkback));
echo "Hey server, TELNET [$x] send: $buf<br>\n";
if ($buf == 'quit') {
$vtSock[$x] = false;
socket_close ($oSock);
}
}
$volta++;
}
}
} while (true);
for ($x=0;$x<$cdSock;$x++) {
$oSock = $vtSock[$x];
if ($oSock != false)
socket_close ($oSock);
}
?>
--
Edit bug report at http://bugs.php.net/?id=23242&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=23242&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=23242&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=23242&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=23242&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=23242&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=23242&r=support
Expected behavior: http://bugs.php.net/fix.php?id=23242&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=23242&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=23242&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=23242&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=23242&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=23242&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=23242&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=23242&r=gnused