lpeterse / haskell-socket

A Haskell binding to the POSIX sockets API
MIT License
47 stars 10 forks source link

Seemingly incorrect C types being used internally #69

Open Melvar opened 3 years ago

Melvar commented 3 years ago

Most obviously, the return type of the system calls send, recv, etc. are given as ssize_t, but the bindings in this library appear to use CInt, which is usually not the same on a 64-bit platform. I believe this works only because the same registers are used by the calling convention regardless of integer size, so the Haskell side simply reads only the low 32 bits, and single messages of 2 GiB size probably would not work anyway.

The reason this came up is that I am writing an extension to this library to send and receive file descriptors with unix domain sockets, which requires me to bind the sendmsg and recvmsg system calls. I used CSsize for the return type and found that the type of System.Socket.Unsafe.tryWaitRetryLoop is incompatible with that – it require CInt to be used.

Some places in the code also appear to use CInt in place of socklen_t, but that does appear to always be the same, according to a cursory search.