IK> I am working on interprocess communication(IPC) in python. In the program
IK> I have, I dynamically bind a port, then fork a child so the child
IK> process knons about the hostname and port number. I pass the information
IK> with parameters and the parent process listening for connection for the
IK> program that child
IK> process executes. As you may know, when a socket object is listening for a
IK> connection, it stops and waits for ever until connection comes in. Howeve=
r,IK> this is what I want exectly. Later I worked out two passible solutions
IK> which requires some special techniques:
IK> 1. Make the connection before fork(), and pass the socket object over
IK> program execution(for example, os.execlp()). I do not really know if
IK> I can do this or not.
IK> 2. Use idle detections with some signal function. This is still not possible
IK> at this time, I have to wait for python 1.0.4 or 1.1, according to Gwido
IK> I am running out of energy at this time. If anyone has a better idea or
IK> solution to passing socket objects, please help me out.
I'm not sure if I got it right, but you seem to use SOCK_STREAM sockets and
*NOT* have the parent process to block in accept() (?). Then, quoting from
accept(2) man page:
" It is possible to select(2) a socket for the purposes of
doing an accept() by selecting it for read."
How about "import select" ?
BTW, I just made an "expect" module to IPC, using plain simple pipes. It does
fork & exec a given program passing some file descriptors (could be sockets).
(Sorry if I missed too many stuff here)
------------------------------------------------------------------------ Jose' Pereira
INESC (Inst. Eng. Sistemas e Computadores) R. Alves Redol 9, 6. 1000 Lisboa, PORTUGAL. Phone.: +351 1 3100223 Fax...: +351 1 525843 e-mail: jmp@inesc.pt PSI...: %(0268)004010314::inesc::jmp
No news is good news.