strange php problem

Chilly

Balls of steel
Joined
Dec 22, 2003
Messages
9,047
This is a upd listen server, used for collecting and parsing game logs from hl2 games, like PVKII or CSS.

I use a crude loop to get data from my FD. After a while (a few thousand loops or so) it starts giving this error:

Warning: socket_select(): no resource arrays were passed to select

Here is the link to the code on pastebin.

http://pastebin.co.uk/11386

Any ideas?

Cheers,

Chilly
 

SheepCow

Bringer of Code
Joined
Dec 22, 2003
Messages
1,365
When starts dying try grabbing the error message, will probably be more helpful

PHP:
socket_strerror(socket_last_error())
 

Chilly

Balls of steel
Joined
Dec 22, 2003
Messages
9,047
I have given the error (its a warning) in my first post.
 

Chilly

Balls of steel
Joined
Dec 22, 2003
Messages
9,047
The socket is working, it's select that isnt.
 

SheepCow

Bringer of Code
Joined
Dec 22, 2003
Messages
1,365
DrChris and Draylor say:
Move the:

Code:
$suxref[] = $sux;

bit to just before the select, inside the loop. The php docs page for socket_select says the arrays can be modified, you need to recreate them.
 

Chilly

Balls of steel
Joined
Dec 22, 2003
Messages
9,047
For anyone that cares, here is the correct code.

Code:
$sux = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
if (!$sux) {
	exit('create error');
}

// designate a port on the socket to recieve data
if (!socket_bind($sux, '1.2.3.4', 7838)) {
	exit('bind error');
}


$ip = '';
$port = 80;
$x = 1000;


while(1) {
		

	unset($suxref);
	$suxref[] = $sux;
	
	
	// let the system take care of polling for UDP data
   	$socket_act = socket_select($suxref, $write = NULL, $except = NULL, NULL);  // sec. timout

    //do some stuff with the socket data
}
 

Users who are viewing this thread

Top Bottom