[openbeosnetteam] Re: socketpair() implementation

I know what it means, what I want is an example of why you would use it. What's the purpose of "creating a pair of connected sockets".


Jérôme Duval wrote:
From http://www.opengroup.org/onlinepubs/009695399/functions/socketpair.html

"create a pair of connected sockets"

Note the word connected, it is important.
Though I don't know what means exactly "unbound pair" ...

Bye,
Jérôme

Selon "info@xxxxxxxxxxxxxx" <info@xxxxxxxxxxxxxx>:


Can anybody tell me why someone would use socketpair instead of just
creating two sockets?  I can't think of a reason to use it.

Philippe Houdoin wrote:

Hi Jerome and teammates ;-)



Please have a look at http://www.haiku-os.org/bugzilla/show_bug.cgi?id=52

to

give feedback or comments. socketpair() isn't on BeOS, but it's kind of
expected to be here IMO.


Well, as it's missing for POSIX 1003.1 compliance, I guess supporting it

will be

great. Not mandatory for R1, thought, but it's not like it's that hard to
implement.



I added a socketpair() prototype in our header sys/socket.h.


I saw this, yes.



My opinion about implementation would be to have a socketpair() in
src/kits/network/libsocket/socket.c which does (for AF_INET at least):
- calls socket() twice to have two sockets.
- call a new ioctl to have the network stack do the socketpair hard job :
bind(), listen(), connect(), accept()
- close the listening socket.


Sounds good to me, indeed.
BTW, these sockets are supposed to be unbounded.



As I never tested the Haiku network part, maybe I'm not the right person to
code this.


Then just implement a noop socketpair() in socket.c (both in libsocket and

in

libnet variant) and I'll self assign the task to implement it later.

I don't consider this as urgent as reaching beta stage of OpenGL Kit and

the

network stack missing features: DHCP, 802.11 support.
Maybe that's because I never used socketpair() so far ;-)

- Philippe











Other related posts: