Is it possible to use UserTimeout socket option on macOS?

Hi all,

I’m currently reading the book Sockets and Pipes by Chris Martin (edited by Julie Moronuki, first edition published 2023-05-09), and experimenting with raw socket programming in Haskell using the network package.

I tried using the following line to set a socket option:

S.setSocketOption s S.UserTimeout 1000

However, when I run this on macOS (Apple Silicon), I get the following runtime error:

*** Exception: Network.Socket.setSockOpt: invalid argument (Invalid argument)

My environment is:

  • GHC: 9.4.8
  • base: 4.17.2.1
  • network: 3.1.4.0
  • OS: macOS

From what I can tell, it seems like UserTimeout isn’t supported on macOS, but I wasn’t able to find a clear explanation or documentation confirming that.

Is there any way to use or emulate UserTimeout behavior on macOS?

Any clarification would be appreciated!

Thanks,

1 Like

I just found this related GitHub issue: haskell/network#571. It seems to confirm that UserTimeout is not supported on macOS, which matches what I’m seeing. Thought it might be helpful to others running into the same issue.

5 Likes