diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2024-07-05 11:07:27 +0200 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2024-07-05 22:13:09 +0200 |
commit | bd351e8d555001647e8501ac2d38c675a2a3c005 (patch) | |
tree | 413c35487f3fd752d7fe1efe941cb58e7474645b /src/Erebos/Network.hs | |
parent | 7729f1be60bf2c4d38758971bd95d4c6445fde1e (diff) |
Broadcast address lookup on Windows
Diffstat (limited to 'src/Erebos/Network.hs')
-rw-r--r-- | src/Erebos/Network.hs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/Erebos/Network.hs b/src/Erebos/Network.hs index 41b6279..3896829 100644 --- a/src/Erebos/Network.hs +++ b/src/Erebos/Network.hs @@ -301,10 +301,11 @@ startServer opt serverOrigHead logd' serverServices = do forkServerThread server $ forever $ do (paddr, msg) <- readFlowIO serverRawPath - case paddr of - DatagramAddress addr -> void $ S.sendTo sock msg addr + handle (\(e :: IOException) -> atomically . logd $ "failed to send packet to " ++ show paddr ++ ": " ++ show e) $ do + case paddr of + DatagramAddress addr -> void $ S.sendTo sock msg addr #ifdef ENABLE_ICE_SUPPORT - PeerIceSession ice -> iceSend ice msg + PeerIceSession ice -> iceSend ice msg #endif forkServerThread server $ forever $ do @@ -922,6 +923,9 @@ getBroadcastAddresses port = do w <- peekElemOff ptr i if w == 0 then return [] else (SockAddrInet port w:) <$> parse (i + 1) - addrs <- parse 0 - cFree ptr - return addrs + if ptr == nullPtr + then return [] + else do + addrs <- parse 0 + cFree ptr + return addrs |