Passing a resource-handle to another script

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
smilodon
Forum Newbie
Posts: 3
Joined: Sun Dec 19, 2004 2:33 am

Passing a resource-handle to another script

Post by smilodon »

Hi All,

I'm writing a small server consiting of two cli-scripts: The first one handles incoming connections, accepts them, and then passes the accepted connection to the second script, that then handles the rest.
This look something like this:

Script 1:
[...]
$ch = socket_accept($listen);

$ch should now be passed to the second script, but I couldn't pass it as command-line argument nor on STDIN..:(

I'm more or less desparately looking for help!
Thanks a lot and best regards,
smilodon
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

why do you have to do the processing between two different scrips?

if you incorperate both scripts this problem will be eliminated.....
smilodon
Forum Newbie
Posts: 3
Joined: Sun Dec 19, 2004 2:33 am

yes but,

Post by smilodon »

this wouldn't allow me to handle mor than one connection concurently
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

ahhh, never thought of that, im not exactly sure how but if im not mistake you can pass that connection through a session var

im assuming it would be something like:

Code: Select all

session_start();
$_SESSION['ch'] = socket_accept($listen);
then as long as you call session start at the begining of the script you should be able to access the connection.....

i think....
smilodon
Forum Newbie
Posts: 3
Joined: Sun Dec 19, 2004 2:33 am

Post by smilodon »

I think I should have been a bit more specific: I'm writing a 'real' Server, like a webserver and therefore I write cli-scripts.
I basically need to pass a resource to another program, and this seems to be impossible (but then, how do other servers handle this?)

best regards,
smilodon
^-- going to bed now 0:25 am
Post Reply