Simon Josefsson wrote: > We could provide replacement functions, perhaps inspired by the > re-implementations in plibc, see > http://cvs.sourceforge.net/viewcvs.py/plibc/plibc/. > ... > The answer seem to be no. So ideally, I think the incompatibilities > should be solved by gnulib.
The Woe32 socket API has three main differences w.r.t. the POSIX socket API: - The type of a socket is 'SOCKET', not 'int'. A SOCKET cannot be used in places where a file descriptor is used. This means in particular that close(), select(), poll() don't work on sockets. But the Woe32 API offers equivalents under different names. - The socket functions don't write into 'errno'. Instead the error code is available from WSAGetLastError(). Also some error code exist with WSA prefix. - You need to call an initialization function WSAStartup(). The plibc layer seems like a lot of code for things that are basically renamings. The way GNU clisp copes with this is a thinner layer: It accepts the facts that a file descriptor and a socket are different things, and that some initialization function is needed, and defines things like #ifdef _WIN32 # define sock_errno WSAGetLastError () # define sock_errno_is(val) (WSAGetLastError () == WSA##val) # define sock_set_errno(val) WSASetLastError (WSA##val) extern int sock_read (...); extern int sock_write (...); #else # define sock_errno errno # define sock_errno_is(val) (errno == val) # define sock_set_errno(val) (void)(errno = val) # define sock_read read # define sock_write write #endif This means that the program code uses slightly different conventions than POSIX, but still someone who knows POSIX can use this API without effort. Do you like that? Or better pure POSIX? Bruno _______________________________________________ bug-gnulib mailing list bug-gnulib@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnulib