-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Socket type is incorrect on Windows #426
Comments
@Mistuke Could you fix it by yourself? |
Yes but I'm not sure how yet. The problem is it's an exported type and we have functions where the I fear this may break a lot of packages. |
|
If we export the following
|
Same as Linux, just 32-bits.
Yeah I don't consider this a blocker, it's been like this for years so.
Yes as it returns But the problem is |
Sorry but I did not know that the size of |
Hmm I though that an |
Do you have a source which explains that |
Not directly, but all the docs for e.g. |
Wow. I misunderstood that |
The size if the "int" type in C is implementation dependent. Historically (very long ago) it was even 16 bits. Now most Unix system have 32-bit ints, but some Unix variants (perhaps Cray systems) IIRC have had 64 bit ints. This is why haskell has a In GHC, despite the documentation in So, the bottom line is that these types are platform-dependent. They do have Now as for Sockets, indeed on Windows an OS Socket is NOT an int, and portable code needs to abstract the type (e.g. in Heimdal Kerberos: This also means that sockets can't directly be converted back and forth to "file descriptors". The Haskell API can convert between Network.Socket |
@vdukhovni Thank you for your explanation. Very clear. |
@kazu-yamamoto I opened an issue on GHC's gitlab that is motivated by this discussion: |
I just updated that issue, it seems that the top-matter (introductory text for the module) already discusses the portability caveat, but it is arguably too easy to miss when one is in a hurry? |
Yes base has a few of those disclaimers around. In particular the Win32 stuff in base are mostly all wrong. For the But in a general sense they're wrong for all platforms where types differ not only by OS but by architecture as well. |
Socket
is defined as holding aCInt
, but on WindowsSOCKET
is an unsigned 64 bit value, usuallyUINT_PTR
. See [1] and [2] this means we may truncate a validSOCKET
to something invalid.[1] https://sourceforge.net/p/mingw-w64/mingw-w64/ci/master/tree/mingw-w64-headers/include/psdk_inc/_socket_types.h
[2] https://docs.microsoft.com/en-us/windows/win32/winsock/socket-data-type-2
The text was updated successfully, but these errors were encountered: