Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Daemon server forking additional children?

Status
Not open for further replies.

thenewa2x

Programmer
Dec 10, 2002
349
US
Hello.

I'm writing a server class in PHP and so far it is working. The is one I would like to implement but I'm not sure how to do it.

What I want to do is fork the process on every incoming connection. This way each connection to the server will spawn a separate process to complete the client's request.

Would I need to accept the connection (socket_accept()) and then fork or is there another way? My assumption would be that on accepting the connection I would have wait for that connection to finish before being able to continue (making forking after accepting a connection useless).

Am I incorrect on this assumption?

TIA

 
Thank you, jpadie but I'm not quite sure what to do with [tt]proc_open()[/tt].

What I wanted to do is have my server listen to a specific port. Once the server receives a connection from a client, the server will fork to handle the request while allowing additional connections to be handled concurrently.

Sorry about my previous post. After re-reading it, the first two sentences was hard to understand even for me :)

 
so you want to write a web server in php? seems inefficient. apache already does this!

is there more detail on what you are doing that you can share?

have you considered, perhaps, a SOAP interface?
 
I am writing an abstract server class for TCP sockets. This class can be extended to perform a variety of services, a web server is just one but even I would advise against that. Also SOAP is limited to XML which can be bulky when sending small bits of data in a live stream.

 
ok.

do you have to return information down the incoming socket connections?
 
I do not have but it is definitely an option I would like to keep open.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top