3Description : Utilities for Network IO.
6Maintainer : The Idris Community.
8module Util.Net (listenOnLocalhost, listenOnLocalhostAnyPort) where
10import Network hiding (socketPort)
11import Network.Socket hiding (sClose, PortNumber)
12import Network.BSD (getProtocolNumber)
13import Control.Exception (bracketOnError)
15-- Copied from upstream impl of listenOn
16-- bound to localhost interface instead of iNADDR_ANY
17listenOnLocalhost (PortNumber port) = do
18 proto <- getProtocolNumber "tcp"
19 localhost <- inet_addr "127.0.0.1"
21 (socket AF_INET Stream proto)
24 setSocketOption sock ReuseAddr 1
25 bindSocket sock (SockAddrInet port localhost)
26 listen sock maxListenQueue
30listenOnLocalhostAnyPort = do
31 proto <- getProtocolNumber "tcp"
32 localhost <- inet_addr "127.0.0.1"
34 (socket AF_INET Stream proto)
37 setSocketOption sock ReuseAddr 1
38 bindSocket sock (SockAddrInet aNY_PORT localhost)
39 listen sock maxListenQueue
40 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