Re: managing tcp fd between parent and child process.



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
.



Relevant Pages

  • Re: Question about pipes
    ... >> (or even pseudo code). ... > It presupposes that on your system, file descriptor zero refers ... > is attached to the read end of the pipe. ... > the child may block if there is insufficient ...
    (comp.os.linux.misc)
  • Re: Question about pipes
    ... >> (or even pseudo code). ... > It presupposes that on your system, file descriptor zero refers ... > is attached to the read end of the pipe. ... > the child may block if there is insufficient ...
    (comp.unix.programmer)
  • SMS 2003 to SCCM 2007 migration
    ... have around 10k clients installed on workstations. ... CH1 represents Site Code for Child primary site currently in the clients ... PA1 represents Site Code for Parent primary site currently in the clients ...
    (microsoft.public.sms.setup)
  • SMS 2003 migrate to SCCM 2007
    ... have around 10k clients installed on workstations. ... CH1 represents Site Code for Child primary site currently in the clients ... PA1 represents Site Code for Parent primary site currently in the clients ...
    (microsoft.public.sms.setup)
  • Re: fork, scanf problem
    ... Once the parent exits, the child gets adopted by a new parent (usually ... Controlling terminal is inherited from the parent process at the time ... terminal until it closes its file descriptor (STDIN_FILENO in this ...
    (comp.unix.programmer)