Socket to which related processes may read/write ?.

Socket to which related processes may read/write ?.

Post by Saripalli Ramakrish » Fri, 21 Aug 1992 07:53:24



Hi ,

        I would like to know if there is any way a socket can be established
        by some ancestor so that all of its descendants might be able to
        monitor the socket(channel) and be able to read/write from/to the
        socket.

        I am specifically interested in sockets because my program uses
        recv() system calls(which I found very useful) and it works only
        on sockets(Even socketpair() would not work).

        I want to use recv() system calls because I want to peek at the
        incoming stream to retrieve the control information which always
        precedes the actual data .For instance,the control information
        contains the actual length(bytes) of the following message,the
        identity of the sender and some other relevant information.

        Of course,the length of the control information is constant across
        all messages.the processes would do recv() on the socket ,peek
        at the incoming stream(MSG_PEEK option of recv()) and remove from
        the stream messages relevant to themselves.

        I need this info very much.I went through Rich Stevens "Network
        Programming in Unix" but I was not able to find the relevant info.

        I would appreciate anyone who could send me this info.I will post
        to the group if there is enough interest.

                                                Thanks in advance,
                                                Saripalli Ramakrishna


Man is a beast and usually has no control over his passions.

 
 
 

Socket to which related processes may read/write ?.

Post by Barry Margol » Sat, 22 Aug 1992 05:59:22



Quote:>    I would like to know if there is any way a socket can be established
>    by some ancestor so that all of its descendants might be able to
>    monitor the socket(channel) and be able to read/write from/to the
>    socket.

If the socket is opened by the ancestor before it forks the children, then
the children will inherit it (just like any other descriptors) and can use
it.

If the socket is opened after the children are spawned, you can use Unix
domain sockets to pass the socket access right to the children.  Stevens
has a section on passing access rights, although I've heard that it doesn't
work in all socket implementations.
--
Barry Margolin
System Manager, Thinking Machines Corp.



 
 
 

1. Sockets: write() writes OK, yet read() reads garbage...?

Strange thing happens. There is a TCP socket established between A and B. Some
information flows OK between the two. However, one particular sequence of
communication does not. A writes a command to B, and immediately goes into
read() for a responce. B does something with the message and writes back to A a
struct, with some fields set to important values. When A reads it (as the same
struct - both use the same header file), however, it contains garbage. All the
fiels are set to 0 (zero). And it reads the correct size of the struct:

  n = read( sock, &preamble, sizeof(preamble) );
  if( n < 0 || n > sizeof(preamble) )
   error...

What/where can the problem be? Does A (or maybe B) have to flush the socket
after it wrote a command, to make sure it does not read its own packet back?

Thanks.
--
Simon   B-)>

2. connecting to a unix system from a windows system(winspock?)

3. Read/Write socket with separate processes?

4. dtmail-resources?

5. Three really bizarre problems that may or may not be related

6. Mount ISO9660 image file

7. iptables woes - may be RELATED related :)

8. Bill Frisbee - M$ Employee?

9. write (socket, buf, 0) and read (socket, buf, 0)

10. Need to sleep after aiowrite (or aio_write) to socket or write may not complete...

11. How to know how many processes are reading the file that is written by a process ?

12. mmap may be slower that read/write!

13. process related to socket?