socket: An extensible socket library.

[ library, mit, network, system ] [ Propose Tags ]

This library is a minimal cross-platform interface for BSD style networking.

[Skip to Readme]


Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS],,,,,,,,,,,,,,,,,,,, (info)
Change log
Dependencies base (>=4.8 && <5), bytestring (<0.12) [details]
License MIT
Author Lars Petersen
Revised Revision 1 made by Bodigrim at 2022-06-15T21:35:27Z
Category System, Network
Home page
Bug tracker
Source repo head: git clone git://
Uploaded by LarsPetersen at 2020-06-29T07:18:38Z
Distributions LTSHaskell:, NixOS:
Reverse Dependencies 8 direct, 1 indirect [details]
Downloads 15896 total (27 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2020-06-29 [all 1 reports]

Readme for socket-

[back to package description]


Available on Hackage License MIT Build Status AppVeyor


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


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


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.


Working, but not regularly tested.

Please report when it is no longer working on MacOS.


  • base
  • bytestring


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.