Why does windows need withSocketsDo?

后端 未结 2 1410
夕颜
夕颜 2021-01-19 05:20

In windows, sockets need to be initialized, as shown in Networks.

On Windows operating systems, the networking subsystem has to be initialised using with

相关标签:
2条回答
  • 2021-01-19 05:39

    In existing versions of the network library, withSocketsDo is used to initialize the Winsock library, which is only a requirement on Windows. On other platforms no library needs initializing, so withSocketsDo does nothing.

    In future versions of the network library, withSocketsDo is called automatically, so only needs to be included for compatibility with older versions, see this blog post for the details behind the changes.

    0 讨论(0)
  • 2021-01-19 05:44

    Windows, unlike other platforms, requires processes to kickstart their network connectivity by manually initializing WinSock.dll. Meanwhile, Haskell, unlike other languages, by design does not have global mutable state. Thus, the WinSock initialization can't be hidden inside the load of a library or creation of some singleton object, and instead needs to be registered manually by an explicit call.

    0 讨论(0)
提交回复
热议问题