简体   繁体   English

如何使用GHC / Haskell的启用epoll / kqueue版本的GHC / Haskell进行网络连接?

[英]How to use the epoll/kqueue enabled version of GHC/Haskell for network connections?

There is a lot of old information on the net regarding an epoll/kqueue enabled GHC. 网上有很多有关启用epoll / kqueue的GHC的旧信息。 For example, the code on the Simple Servers wiki page doesn't compile anymore. 例如,“ 简单服务器”维基页面上的代码不再编译。

Could someone provide a basic example of how to use this feature with a modern GHC version to build, eg a TCP server that just responds with "Hello" on connect? 有人可以提供一个如何在现代GHC版本中使用此功能的基本示例,例如,仅在连接时以“ Hello”响应的TCP服务器吗?

GHC's IO manager uses epoll/kqueue under the hood without any special programmer effort. GHC的IO管理器在后台使用epoll / kqueue,而无需任何特殊的程序员工作。 Just write the naive threaded program -- that puts each concurrent blocking IO call in a separate thread -- and GHC will make sure it works out the way you want it to. 只需编写朴素的线程程序-将每个并发阻塞的IO调用放在单独的线程中-GHC将确保它按照您希望的方式工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM