bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: RFC socketpair


From: Bruno Haible
Subject: Re: RFC socketpair
Date: Thu, 7 Apr 2011 01:12:51 +0200
User-agent: KMail/1.9.9

Hi Bastien,

> A request for comment for a socketpair for windows.
>
> Please comment.

I think it is too early for us to comment, because it appears that you have not
yet started to compile and test the code:

> int
> socketpair (int domain, int type, int protocol, int sv[2])
> {
>   return raw_socketpair (int domain, int type, int protocol, int sv[2]);
> }

I'm not aware of any compiler that would accept this syntax.

To which platforms do you have access to? On which systems can you test code?

If you don't have access to Windows systems, then you could still write an
implementation that works on Linux, FreeBSD, etc. and that uses only "simple"
socket API functions - those that are present in <winsock2.h> and documented
on msdn.microsoft.com -, in the hope to minimize the subsequent porting effort
to Win32.

Of course, if you want to do this, you also need a test program.

In fact, the test program would be the first thing I would write, because I
don't know how socketpair() is meant to behave and the implementations out
there don't give me a clue either:

  - One implementation supports only d == AF_UNIX, type == SOCK_STREAM,
    protocol == 0, and uses the pipe() function.

  - Another implementation supports only d == AF_UNIX, type == SOCK_DGRAM,
    protocol == PF_UNIX, and calls in this order
      socket()
      bind()
      getsockname()
      socket()
      bind()
      getsockname()
      connect()
      connect()

  - Another implementation calls in this order
      socket()
      bind()
      listen()
      socket()
      connect()
      accept()

  - Another one calls
      socket()
      bind()
      getsockname()
      listen()
      socket()
      connect()
      accept()

Once you have a test program - and it works with the native Linux and FreeBSD
socketpair() system calls -, this test program will give confidence that the
implementation based on simpler socket API calls is working.

Bruno
-- 
In memoriam The children of Izieu <http://fr.wikipedia.org/wiki/Enfants_d'Izieu>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]