P K
P K

Reputation: 10210

PHP - How to read up to EOF - socket resource?

I want to read socket resource up to end of file.

$socket = fsockopen($ip,3083);
fwrite($fh,fread($socket,800));

How to implement EOF instead of some specific number like 800.

Upvotes: 1

Views: 2937

Answers (1)

wonk0
wonk0

Reputation: 13952

Something like

while( !feof( $socket ) ) {
 fwrite( $fh, fread( $socket, 800 ) );
}

should do the job. cf. feof()

Upvotes: 1

Related Questions