Re: managing tcp fd between parent and child process.
- From: jt@xxxxxxxxxxx (Jens Thoms Toerring)
- Date: 16 Dec 2006 18:36:37 GMT
vijay_kh_2000@xxxxxxxxx wrote:
I need to develop a tcp server which takes and validate the information
from clients. Upon the validation, I need to create/replace the parent
with child process which would process the further request from client
without breaking the tcp connection.
How do I pass the FD to in case of execlp ?(probably by passing as
input argument)
You can't pass a file descriptor as one of the argument - it's just
an integer number that has no meaning in the exec-ed program. There's
some way to pass an open file descriptor to an unrelated process
but I have never tried it and it is probably too complicated for
your case.
How about if I use fork () ? (probably using the same FD as parent is
using)
which is the best approach for this problem. How do I handle exit,
closing of the FDs.
Unless something else forces you to I would go with the fork()
approach. The child "inherits" the file descriptor and does it's
work with it while the parent just closes it immediately (no harm
done that way since the child has it still open). Once the child
is done with the file descriptor it also closes it (either expli-
citely or by simply by exiting), thereby closing the connection.
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@xxxxxxxxxxx
\__________________________ http://toerring.de
.
- Follow-Ups:
- Re: managing tcp fd between parent and child process.
- From: Casper H . S . Dik
- Re: managing tcp fd between parent and child process.
- From: vijay_kh_2000
- Re: managing tcp fd between parent and child process.
- References:
- managing tcp fd between parent and child process.
- From: vijay_kh_2000
- managing tcp fd between parent and child process.
- Prev by Date: Re: fscanf/fprintf usage
- Next by Date: Re: managing tcp fd between parent and child process.
- Previous by thread: managing tcp fd between parent and child process.
- Next by thread: Re: managing tcp fd between parent and child process.
- Index(es):
Relevant Pages
|