It's in Python. It just _works_!

Jp Calderone exarkun at divmod.com
Fri Sep 3 17:33:35 EDT 2004


Elbert Lev wrote:
> Tim Peters <tim.peters at gmail.com> wrote in message news:<mailman.2799.1094175262.5135.python-list at python.org>...
> 
>>[Grant Edwards]
>>
>>>...
>>>Apparently, the file descriptor you get from a socket object
>>>under Win32 can't be used with os.read() and os.write()?  I
>>>couldn't find anywhere in the docs that said so, but I sure
>>>couldn't get it to work.  At least not under WinMe.
>>
>>Socket handles and file descriptors are disjoint concepts in Windows
>>(any flavor), and aren't interchangeable in any context.
> 
> 
> Not exactly. In WIN32 API WriteFile() one can use SOCKET and file
> handle returned by CreateFile(). os.read() uses handles returned by
> open(), which on WIN32 are not the same as returned by CreateFile.

   Note he said "socket handles" and "file descriptors" while you are 
talking about "socket handles" and "file handles".  On Windows, file 
descriptors exist, but they are just a compatibility layer over some 
kind of handle.  This compatibility layer is generally fairly limited, 
and only allows file descriptors to be used in certain contexts.

   If you use the real handles and the real win32 APIs (which you can do 
with the pywin32 extension), things are indeed much more consistent.

   Jp



More information about the Python-list mailing list