• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

lpeterse/haskell-socket: A Haskell binding to the POSIX sockets API

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

lpeterse/haskell-socket

开源软件地址(OpenSource Url):

https://github.com/lpeterse/haskell-socket

开源编程语言(OpenSource Language):

Haskell 88.4%

开源软件介绍(OpenSource Introduction):

socket

Available on Hackage License MIT Build Status AppVeyor

Motivation

This library aims to expose a minimal and cross-platform interface for BSD style networking code.

Implementation Philosophy

  • Every operation and every flag exposed should be supported with same semantics on every platform. If this cannot be guaranteed it should be supplied by another (extension) package.

  • Absolutely no conditional exports.

  • No #ifdef madness in the Haskell sources. The Haskell binding code uses the FFI to reference platform dependant C functions for each operation. If a platform is not POSIX compliant (i.e. Windows) equivalent functionality is implemented by using whatever the platform specific building blocks are.

Platform Support

Linux

Platform is fully supported. Each commit and release is automatically tested with Travis CI and several versions of GHC.

Windows

Fully supported on Windows7 (maybe Vista) or higher :-)

GHC's runtime system on Windows does not offer an event notification mechanism for sockets. The original network library suffers from this, too. For example, connection attempts are non-interruptible etc. The approach taken to circumvent this in this library is to poll the non-blocking sockets with increasing delay. This guarantees interruptibility and fairness between different threads. It allows for decent throughput while also keeping CPU consumption on a moderate level if a socket has not seen events for a longer period of time (maximum of 1 second delay after 20 polling iterations). The only drawback is potentially reduced response time of your application. The good part: Heavy load (e.g. connection requests or incoming traffic) will reduce this problem. Eventually your accepting thread won't wait at all if there are several connection requests queued.

This workaround may be removed if someone is willing to sacrifice to improve the IO manager on Windows.

Each commit and release is automatically tested with AppVeyor continuous integration.

MacOS

Working, but not regularly tested.

Please report when it is no longer working on MacOS.

Dependencies

  • base
  • bytestring

Tests

The project uses tasty for testing.

There are two test suites: default and threaded which share the same code. The only difference is that one is compiled against GHC's single threaded RTS and the other against the multi-threaded one. Run cabal test or stack test to execute both in sequence.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap