bug-gnulib
[Top][All Lists]
Advanced

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

Re: winsock: needs access to SOCKET in application code


From: Paolo Bonzini
Subject: Re: winsock: needs access to SOCKET in application code
Date: Tue, 14 Oct 2008 15:52:51 +0200
User-agent: Thunderbird 2.0.0.17 (Macintosh/20080914)

> I need to pass a SOCKET handle to GnuTLS, instead of the FD handle that
> winsock wrappers created.

You can also install your own GnuTLS transport handlers using read and
write.  It would probably be less code and less complication than
toggling between descriptors and sockets.

>> SOCKET _gl_fd_to_socket (int fd)
>> {
>>   return FD_TO_SOCKET(fd);
>> }
>> ...
>> This approach is unclean: the code is not written in portable POSIX
>> style.
> 
> Indeed. You could have completely POSIX code in gsasl if the library's
> API offered each socket related API in a variant that takes a SOCKET
> argument and another variablt which takes an 'fd' argument.
> 
> But if you were only the maintainer of gsasl, and the library was not
> under your control, this cleaner approach is not possible, and you need
> to adapt gsasl to the data types supported by the library. So, yes, I agree,
> gnulib should export this _gl_fd_to_socket function (without leading
> underscore, once it's supported).

I agree, but it needs to be thought out...  Should it be supported for
POSIX sockets too?  In that case, you don't have SOCKET at all, so what
should the prototype be?

>> int _gl_socket_to_fd (SOCKET fh)
>> {
>>   return SOCKET_TO_FD(fh);
>> }
> 
> This would be a problem, however. If you have a library which creates
> SOCKET objects, then they need to be non-overlapping in order to work
> with ReadFile/WriteFile, as Paolo said. How could that be guaranteed?

Do you need this or is it only for symmetry?

Paolo




reply via email to

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