Operating System - OpenVMS
1753357 Members
5010 Online
108792 Solutions
New Discussion юеВ

Re: Passing socket/file descriptors between processes?

 
Martin Cowie
Occasional Contributor

Passing socket/file descriptors between processes?

I'm unsure if the answers I'll get to this question will be all that polite, as this is pretty high octane stuff on Unix =)

Can I pass a socket descriptor from a parent process to a child process on VMS? By "passing a descriptor descriptor" I mean actually passing the ownership of the socket from one process to another - a little more that writing a 4 byte integer down a pipe.

Traditionally BSD and and SysV employ different approaches of achieving this, but both of them rely on a pipe between the two processes.

Does anyone know if the C RTL supports either mechanism, should I look into using the underlying system services, or give up altogether?

My thanks again for your headscratching,

M.

5 REPLIES 5
Ian Miller.
Honored Contributor

Re: Passing socket/file descriptors between processes?

the full fork semantics are not implemented on VMS (its being thought about).

does vfork do what you want?
See
http://h71000.www7.hp.com/commercial/c/docs/5763pro_047.html#index_x_1307
and
http://h71000.www7.hp.com/commercial/c/docs/5763pro_064.html#index_x_1727
____________________
Purely Personal Opinion
Bojan Nemec
Honored Contributor

Re: Passing socket/file descriptors between processes?

Martin,

In this Ask the Wizard you have an example on how to pass a socket to a subprocess:

http://h71000.www7.hp.com/wizard/wiz_3995.html

Bojan
Martin Cowie
Occasional Contributor

Re: Passing socket/file descriptors between processes?

I should really be more specific - I'm looking to find out how a socket can be passed from a parent to a child process, *after* the vfork/exec combination.
Bojan Nemec
Honored Contributor

Re: Passing socket/file descriptors between processes?

Martin,

The example in the link in my previous post does yust that. Unfortunately it is writen in the $qio interface to sockets, which is more difficult to understand for an Unix guy.

In short:
The example (PARENT.C) listen for an incoming connection, when the connection is established creates a subprocess (CHILD.C) calling lib$spawn and pass the socket to it (using a mailbox). Then this subprocess comunicates with the client on that socket.

Probably the line
$DESCRIPTOR(command, "run serverc_qio2");
should be
$DESCRIPTOR(command, "run child");


Bojan
Vouters
Advisor

Re: Passing socket/file descriptors between processes?