[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freebsd-hackers
Subject:    Re: socketpair(2)
From:       Terry Lambert <tlambert () primenet ! com>
Date:       1999-01-31 0:47:42
[Download RAW message or body]

> Right, but it seems as though a UNIX domain socket will allow a process to
> read off the socket that which it has just written, when bidirectional,
> correct? (Or am I doing something wrong?)

Use two socketpair's.

> It would be nice if two connected processes could send data back and
> forth without reading off their own output, and a TCP connection 
> implements this.  (I think this is similar to a channel under Plan 9/Alef,
> but I do not know for certain due to lack of access.)  

Depending on these semantics is bad, even if you make it work in
your particular kernel.


> Have I missed something here?

Your best bet would be to bind to 127.0.0.1, and use the standard
bind/list/accept/connect to get real sockets over the loopback
interface.

If you had a dire need, you could name the function that encapsulated
the whole process "socketpair".

Since the connect won't complete until the accept, you will need
to fork a child to call connect.

If you were moderately insane, you'd set up a socketpair(2) to
pass the descriptor back to the parent, and then make the child
exit so that it looked like a single process function with a
lump in it.  8-).


					Terry Lambert
					terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic