parent ->forks-> child->execs->another program
parent must communicate two-ways or one-way with other program ?
- presumably pipes are not good enough (one or two way) ?
- if you want sockets, do a listen then do select on the file
descriptor, and when this completes, do accept, so:
s = socket (AF_INET, SOCK_STREAM, 0)
s.bind ((222.222.222.222, 1040))
s.listen (1)
^^^^^^^^^^^^^^^^^^^^^^Program stops here.
read, write, exc = select ([s.fileno()],[],[], timeout)
if s.fileno() in read:
news = s.accept ()
s.close()
Note: this is quick hack, use with care :-)
Adrian
-- ------------------------------------------------------------------------- = Adrian Phillips at | BUT any thoughts in this are purely = = The Norwegian Meteorological | my own and have nothing to do with = = Institute | this establishment, thankfully. = = Net: adrian.phillips@dnmi.no | Phone: 47 22 96 32 09 Fax: 47 22 96 30 50This is similar to what I am using right now, The problem is the program stops at listening until having a connection. Rest of the program will not be executed until a connection comes in. So I can either doing idle detection with some timer which sends out signal or having connection before forking a child and passing the socket object to the new program that child executes.
-- +--------------------------------------------------------------------+ | I-feng Kao internet : ikao@eecs.wsu.edu | | (E-FONG) i8974949@wsuaix.csc.wsu.edu | | kao@wsuvm1.csc.wsu.edu | | Friends coming from far away make me happy. | +--------------------------------------------------------------------+
-- +--------------------------------------------------------------------+ | I-feng Kao E-mail : ikao@eecs.wsu.edu | | i8974949@wsuaix.csc.wsu.edu | | kao@wsuvm1.csc.wsu.edu |