如何使用GHC / Haskell的启用epoll / kqueue的版本进行网络连接? [英] How to use the epoll/kqueue enabled version of GHC/Haskell for network connections?

查看:167
本文介绍了如何使用GHC / Haskell的启用epoll / kqueue的版本进行网络连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

网络上有许多关于启用了epoll / kqueue的GHC的旧信息。例如,简单服务器wiki页上的代码不再编译。



有人可以提供一个基本的例子,说明如何使用这个特性和现代GHC版本来构建,例如一个TCP服务器,只是在连接上响应Hello?

解决方案

GHC的IO管理器使用epoll / kqueue特别程序员的努力。只需编写简单的线程程序 - 将每个并发的阻塞IO调用放入一个单独的线程 - GHC将确保它按照您希望的方式工作。


There is a lot of old information on the net regarding an epoll/kqueue enabled 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, e.g. a TCP server that just responds with "Hello" on connect?

解决方案

GHC's IO manager uses epoll/kqueue under the hood without any special programmer effort. 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.

这篇关于如何使用GHC / Haskell的启用epoll / kqueue的版本进行网络连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆