keep-alive: TCP keep alive implementation

[ bsd3, library, network ] [ Propose Tags ]

This module allows you to set per-connection keep alive parameters on windows, linux and darwin enviroments. For more information on keep alive signals see https://en.wikipedia.org/wiki/Keepalive. See also https://tldp.org/HOWTO/html_single/TCP-Keepalive-HOWTO/ for a linux specific implementation.


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0, 0.1.1.0, 0.2.0.0, 0.2.1.0
Change log ChangeLog.md
Dependencies base (>=4.9 && <5) [details]
License BSD-3-Clause
Copyright 2020 Kyriakos Papachrysanthou
Author Kyriakos Papachrysanthou
Maintainer papachrysanthou.k@gmail.com
Category Network
Home page https://github.com/3kyro/keep-alive#readme
Bug tracker https://github.com/3kyro/keep-alive/issues
Source repo head: git clone https://github.com/3kyro/keep-alive
Uploaded by 3kyro at 2022-06-13T09:44:05Z
Distributions LTSHaskell:0.2.1.0, NixOS:0.2.1.0, Stackage:0.2.1.0
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 786 total (24 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2022-06-13 [all 1 reports]

Readme for keep-alive-0.2.1.0

[back to package description]

keep-alive

This module allows you to set per-connection keep alive parameters on windows and linux enviroments. For more information on keep alive signals see https://en.wikipedia.org/wiki/Keepalive. See also https://tldp.org/HOWTO/html_single/TCP-Keepalive-HOWTO/ for a linux specific implementation.

The module is meant to be used in conjuction with the "network" package. However, in order to ensure adaptability, all functions require a socket file descriptor instead of an implementation dependent socket type. For the network package, such a descriptor can be obtained with the withFdSocket function:

 -- sock is a Socket type
 withFdSocket sock $ \fd -> do
    before <- getKeepAliveOnOff fd
    print before -- False
    -- set keep alive on, idle 60 seconds, interval 2 seconds
    rlt <- setKeepAlive fd $ KeepAlive True 60 2
    case rlt of
        Left err -> print err
        Right () -> return ()
    after <- getKeepAliveOnOff fd
    print after -- True

Please note that only the envocing process can manipulate sockets based on their file descriptors.