php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23242 socket_read(): linux "stop" with 2 or more users connected...
Submitted: 2003-04-16 12:10 UTC Modified: 2003-04-28 11:45 UTC
Votes:5
Avg. Score:3.6 ± 1.5
Reproduced:2 of 3 (66.7%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: david at wups dot net Assigned:
Status: No Feedback Package: Sockets related
PHP Version: 4.3.1 OS: MDK 8.2 / windows xp
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
40 + 26 = ?
Subscribe to this entry?

 
 [2003-04-16 12:10 UTC] david at wups dot net
 
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);
  
}
 
?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-04-28 11:45 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 04:01:28 2024 UTC