catch and print all Socket bind exceptions
This commit is contained in:
parent
1fc264a226
commit
3c28cde942
|
@ -865,7 +865,7 @@ mkServerSocket ip port = do
|
||||||
sockAddr <- addrAddress <$> resolve (Just $ show . fromHostAddress6 $ ip) (Just port)
|
sockAddr <- addrAddress <$> resolve (Just $ show . fromHostAddress6 $ ip) (Just port)
|
||||||
sock <- socket AF_INET6 Datagram defaultProtocol
|
sock <- socket AF_INET6 Datagram defaultProtocol
|
||||||
setSocketOption sock IPv6Only 1
|
setSocketOption sock IPv6Only 1
|
||||||
bind sock sockAddr
|
bind sock sockAddr `catch` (\e -> putStrLn $ "Caught exception while bind " <> show sock <> " " <> show sockAddr <> ": " <> show (e :: SomeException))
|
||||||
pure sock
|
pure sock
|
||||||
|
|
||||||
-- | create a UDP datagram socket, connected to a destination.
|
-- | create a UDP datagram socket, connected to a destination.
|
||||||
|
@ -881,6 +881,6 @@ mkSendSocket srcIp dest destPort = do
|
||||||
setSocketOption sendSock IPv6Only 1
|
setSocketOption sendSock IPv6Only 1
|
||||||
-- bind to the configured local IP to make sure that outgoing packets are sent from
|
-- bind to the configured local IP to make sure that outgoing packets are sent from
|
||||||
-- this source address
|
-- this source address
|
||||||
bind sendSock srcAddr
|
bind sendSock srcAddr `catch` (\e -> putStrLn $ "Caught exception while mkSendSocket bind " <> show sendSock <> " " <> show srcAddr <> ": " <> show (e :: SomeException))
|
||||||
connect sendSock destAddr
|
connect sendSock destAddr
|
||||||
pure sendSock
|
pure sendSock
|
||||||
|
|
Loading…
Reference in a new issue