php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15813 >3 step communications
Submitted: 2002-03-01 11:21 UTC Modified: 2002-07-01 17:37 UTC
Votes:7
Avg. Score:4.6 ± 0.7
Reproduced:5 of 5 (100.0%)
Same Version:4 (80.0%)
Same OS:2 (40.0%)
From: karl at crantorland dot com Assigned:
Status: Not a bug Package: Sockets related
PHP Version: 4.1.1 OS: windows nt 4.0
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 !
Your email address:
MUST BE VALID
Solve the problem:
44 - 10 = ?
Subscribe to this entry?

 
 [2002-03-01 11:21 UTC] karl at crantorland dot com
PHP is unrelyable in telling when data has arrived on a socket.  socket_get_status() once the feof has resulted in true will never reset even when data has arrived.  I have done extensive testing.  I connect to an smtp server so i know the server side is working.  this is what is suppose to happen:

1)client connects
2)server accepts and sends 220 ready reponse
3)client recieves 220 and sends EHLO to server
4)server recives EHLO and sends back 250 reponse along with supported options
5)client recives 250 reponse(smtp goes on with more stuff but this is the point where my script would disconnect)

i use a while(!feof($socket)) loop to get all the data off the port.  the first one works and then after that no matter what data arrives feof($socket) is always true.

socket_get_status($socket) confirms that php thinks no more has arrived but when i look at the server i can see that data has been sent.

This was all done under 4.1.0.  i upgraded to 4.1.1 and now nothing works at all.

testing code is here.  feel free to connect to the server and port specified for testing.
http://dcl.nvps.net/socket.phps
http://dcl.nvps.net/socket.php

If i am wrong about this and someone has a script that proves me wrong please email it to me and disregard this post.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-03-01 11:24 UTC] exonic at signuts dot net
I experience the same problem. I'm using PHP4.1.2
 [2002-07-01 17:37 UTC] jason@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately your version of PHP is too old -- the problem
might already be fixed. Please download a new PHP
version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.


 [2004-06-30 17:17 UTC] ggarber at searchtec dot com
Here's your problem and this works for me.
Took me a few days to figure this one out.
Right now I'm working on serial communications in php.
It seems it can be done but only with some effort.
(under windows nt, xp, 95, etc)
well here's the telnet code..
------------------
function telnet_get_til_input($socket=0)
{
$response = '';

if ($socket === 0) { return 0; }

$line = fgets($socket, 1024);
$response = $line;

while ((!feof($socket)) and (!($line === false)))
  {
   $line = fgets($socket, 1024);
   if ($debugging) { echo $line; }
   $response .= $line;
  }

return $response;
}; // end function telnet_get_til_input
------------------
you might also want to make sure you put this code to connect
------------------
function telnet_connect($server='127.0.0.1',$port='23')
{
$socket = 0;
$socket = fsockopen($server, $port);
socket_set_timeout($socket,2,0);
$response = telnet_get_til_input($socket);

return $socket;
}; // end function telnet_connect
------------------
and here's the disconnect code
------------------
function telnet_quit($socket)
{
return fclose($socket);
}; // end function telnet_quit
------------------
you might want to edit those a lot to have extra commands in them.. but they work good.
let's get some posts on com ports under windows and linux for php.. talk about limited..
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 07:01:29 2024 UTC