socket_read warning?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dappa
Forum Newbie
Posts: 5
Joined: Sun Feb 04, 2007 1:36 pm

socket_read warning?

Post 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
arukomp
Forum Contributor
Posts: 113
Joined: Sun Sep 24, 2006 4:22 am

Post 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);
dappa
Forum Newbie
Posts: 5
Joined: Sun Feb 04, 2007 1:36 pm

Post 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
arukomp
Forum Contributor
Posts: 113
Joined: Sun Sep 24, 2006 4:22 am

Post 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.
dappa
Forum Newbie
Posts: 5
Joined: Sun Feb 04, 2007 1:36 pm

Post 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.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

please post the first 30 or 31 lines of the script.
Post Reply