Hello Guys!

 

I'm having troubles with not knowing the amount of data which is waiting
to be received in the buffer for a specific socket I can use fsockopen,
establish a connection, and write to the socket, I can read from the
socket just fine as well. The trouble I'm running into is illustrated in
this example

 

Eg: Open a socket to an ftp site (port 21). I can expect a banner from 

EG: the ftp server, but this is not always the case. if there is a 

EG: banner it is usually only one line, but this is not always the case.

EG: I can then fputs($fp, 'user anonymous'.chr(10)); After that fputs I 

EG: can expect one line to be in the buffer. I then fputs($fp, 'pass 

EG: [EMAIL PROTECTED]'.chr(10)); There can then be anything from 0 to 

EG: (lots) of bytes in the buffer, spanning multiple lines.

 

I want to be able to pull all of the waiting information out of the
socket, process it, and then proceed - not knowing the amount of data to
expect.  A while( $data=fgets($fp, 9999) ) works, but either a) hangs
when there is no more data to receive, or b) times the socket out when a
socket timeout on the file pointer is used, or c) is VERY unreliable
when the socket is set to non-blocking mode.  I've tried using
$var=socket_get_status($fp), but then $var['unread_bytes'] is always 0
or null... Am I missing something?

 

The development server is running slackware 8, kernel 2.4.18,
apache-1.3.24, and php 4.2

 

I'll send sample code if asked, Thanks in advance for the help!

 

 

 

 
------------------------------------------------------------------------
-

  -- Demitrious S. Kelly

  -- Eagle Networks

 
------------------------------------------------------------------------
-

 

 

 

 
------------------------------------------------------------------------
-

  -- Demitrious S. Kelly

  -- Eagle Networks

 
------------------------------------------------------------------------
-

 

Reply via email to