Page 1 of 1

socket_read warning?

Posted: Sat Jun 16, 2007 4:31 am
by dappa
I got this warning:

Warning: socket_read(): 1 is not a valid Socket resource in
test.php on line 30

from line 30:

$out = socket_read($socket, 2048, PHP_BINARY_READ);

Exactly same code worked well on other web-server, and now it makes that warning. What's wrong.

Thanks for your help

Posted: Sat Jun 16, 2007 5:17 am
by arukomp
I wonder what value has $socket variable.
echo $socket value before that error and tell me what does it output

Code: Select all

echo $socket;
$out = socket_read($socket, 2048, PHP_BINARY_READ);

Posted: Sat Jun 16, 2007 6:29 am
by dappa
arukomp wrote:I wonder what value has $socket variable.
echo $socket value before that error and tell me what does it output
echo $socket; prints this message:

Resource id #1

This script worked well on my old webhost, but on this new server it gives right results from that socket connection, but on the bottom of every result page there is that

Warning: socket_read(): 1 is not a valid Socket resource in
test.php on line 30

Posted: Sat Jun 16, 2007 6:39 am
by arukomp
hm... I think you may want to check the manual for socket_read() function and see what it tells about the php version that you are trying to run the script.

Posted: Sat Jun 16, 2007 7:10 am
by dappa
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);

This is how I make socket-variable, which produces "Resource id #1"

that causes Warning: socket_read(): 1 is not a valid Socket resource in
test.php on line 30

What other socket resource ids there are and how to produce them in $socket = line.

Once again, those lines worked on old server, and I didn't find anythink on that warning on google.

Posted: Sat Jun 16, 2007 9:08 am
by volka
please post the first 30 or 31 lines of the script.