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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: david at wups dot net
New email:
PHP Version: OS:

 

 [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-2022 The PHP Group
All rights reserved.
Last updated: Tue Nov 29 17:05:53 2022 UTC