Skip to content

Commit 4c641cc

Browse files
authored
Merge pull request #69 from ysangkok/no-network-bsd
Remove network-bsd, use defaultProtocol
2 parents 96b1492 + 5eb8498 commit 4c641cc

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

happstack-server.cabal

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ Library
6363

6464
if flag(network-uri)
6565
build-depends: network >= 3.0.0 && < 3.2,
66-
network-bsd >= 2.8.1 && < 2.9,
6766
network-uri >= 2.6 && < 2.7
6867
else
6968
build-depends: network < 2.6

src/Happstack/Server/Internal/Listen.hs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import Control.Exception.Extensible as E
1111
import Control.Concurrent (forkIO, killThread, myThreadId)
1212
import Control.Monad
1313
import qualified Data.Maybe as Maybe
14-
import Network.BSD (getProtocolNumber)
1514
import qualified Network.Socket as Socket
1615
import System.IO.Error (isFullError)
16+
import Foreign.C (CInt)
1717
{-
1818
#ifndef mingw32_HOST_OS
1919
-}
@@ -25,6 +25,12 @@ import System.Log.Logger (Priority(..), logM)
2525
log':: Priority -> String -> IO ()
2626
log' = logM "Happstack.Server.HTTP.Listen"
2727

28+
-- Meant to be TCP in practise.
29+
-- See https://www.gnu.org/software/libc/manual/html_node/Creating-a-Socket.html
30+
-- which says "zero is usually right". It could theoretically be SCTP, but it
31+
-- would be a bizarre system that defaults to SCTP over TCP.
32+
proto :: CInt
33+
proto = Socket.defaultProtocol
2834

2935
{-
3036
Network.listenOn binds randomly to IPv4 or IPv6 or both,
@@ -34,7 +40,6 @@ log' = logM "Happstack.Server.HTTP.Listen"
3440

3541
listenOn :: Int -> IO Socket.Socket
3642
listenOn portm = do
37-
proto <- getProtocolNumber "tcp"
3843
E.bracketOnError
3944
(Socket.socket Socket.AF_INET Socket.Stream proto)
4045
(Socket.close)
@@ -49,7 +54,6 @@ listenOnIPv4 :: String -- ^ IP address to listen on (must be an IP address not
4954
-> Int -- ^ port number to listen on
5055
-> IO Socket.Socket
5156
listenOnIPv4 ip portm = do
52-
proto <- getProtocolNumber "tcp"
5357
hostAddr <- inet_addr ip
5458
E.bracketOnError
5559
(Socket.socket Socket.AF_INET Socket.Stream proto)

0 commit comments

Comments
 (0)