unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Re: read() and write() for MinGW
       [not found]   ` <4BB06BDA.8020909@gnu.org>
@ 2010-03-29 21:32     ` Neil Jerram
  0 siblings, 0 replies; only message in thread
From: Neil Jerram @ 2010-03-29 21:32 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: bug-gnulib, Bruno Haible, Guile Development

Paolo Bonzini <bonzini@gnu.org> writes:

>>> Conceptually this is extremely simple, and I've found that gnulib
>>> already contains useful bits like SOCKET_TO_FD, FD_TO_SOCKET, and the
>>> code for determining if an arbitrary fd is a socket - which is all
>>> great.
>>
>> Yes, and the read() and write() functions don't need to make this
>> distinction, because they call ReadFile and WriteFile, which work
>> equally fine with HANDLEs and SOCKETs.

Thanks Bruno.  I hope I understood your reply correctly.  What I took
from it was that read() and write() only don't work when they are called
with the wrong type of ID - i.e. a SOCKET instead of a file descriptor -
and that they are fine so long as the correct ID conversion is done,
using _open_osfhandle().  I hope that's correct.

> ... but not for all sockets, only those created by gnulib's socket:
>
>   /* We have to use WSASocket() to create non-overlapped IO sockets.
>      Overlapped IO sockets cannot be used with read/write.  */
>   fh = WSASocket (domain, type, protocol, NULL, 0, 0);
>
> Neil, can you make sure that all your sockets are gnulib-created?

I'm not sure.

Guile's API, on both C and Scheme level, reflects the traditional
Unix/Linux sockets API, which I believe has no equivalent of Windows'
overlapped operation.  So in that sense Guile has no requirement to
support overlapped sockets.

However...

- MSDN says [1] that a non-blocking socket must be overlapped (if I'm
  understanding the article correctly), and it would be quite
  undesirable for Guile to exclude non-blocking socket operation on
  MinGW.

  [1] http://support.microsoft.com/kb/181611

- Guile's C API allows constructing a Scheme port around an arbitrary
  file descriptor - so ideally that would still work for any kind of
  Windows socket for which it's possible to obtain a file descriptor.

Can you let me know your thoughts on those points?

Thanks,
       Neil




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-03-29 21:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <87hbo0p0fr.fsf@ossau.uklinux.net>
     [not found] ` <201003290040.11094.bruno@clisp.org>
     [not found]   ` <4BB06BDA.8020909@gnu.org>
2010-03-29 21:32     ` read() and write() for MinGW Neil Jerram

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).