3Description : Utilities for Network IO.
6Maintainer : The Idris Community.
8module Util.Net (listenOnLocalhost, listenOnLocalhostAnyPort) where
10import Control.Exception (bracketOnError)
12-- Copied from upstream impl of listenOn
13-- bound to localhost interface instead of iNADDR_ANY
14listenOnLocalhost :: PortNumber -> IO Socket
15listenOnLocalhost port = do
16 let hints = defaultHints { addrSocketType = Stream }
17 localhost:_ <- getAddrInfo (Just hints) (Just "127.0.0.1") (Just $ show port)
19 (socket AF_INET Stream defaultProtocol)
22 setSocketOption sock ReuseAddr 1
23 bind sock (addrAddress localhost)
24 listen sock maxListenQueue
28listenOnLocalhostAnyPort :: IO (Socket, PortNumber)
29listenOnLocalhostAnyPort = do
30 let hints = defaultHints { addrSocketType = Stream }
31 localhost:_ <- getAddrInfo (Just hints) (Just "127.0.0.1") (Just "0")
33 (socket AF_INET Stream defaultProtocol)
36 setSocketOption sock ReuseAddr 1
37 bind sock (addrAddress localhost)
38 listen sock maxListenQueue
39 port <- socketPort sock
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list