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