switch away from deprecated interface

Again the new stuff works back to network-2.4, so no need to adjust cabal
bounds.
This commit is contained in:
Joey Hess 2016-09-05 14:39:44 -04:00
parent 12db586469
commit 29b6ab467a
No known key found for this signature in database
GPG key ID: C910D9222512E3C7
2 changed files with 7 additions and 4 deletions

View file

@ -127,12 +127,12 @@ getSocket h = do
go' :: Int -> AddrInfo -> IO Socket
go' 0 _ = error "unable to bind to local socket"
go' n addr = do
r <- tryIO $ bracketOnError (open addr) sClose (useaddr addr)
r <- tryIO $ bracketOnError (open addr) close (useaddr addr)
either (const $ go' (pred n) addr) return r
open addr = socket (addrFamily addr) (addrSocketType addr) (addrProtocol addr)
useaddr addr sock = do
preparesocket sock
bindSocket sock (addrAddress addr)
bind sock (addrAddress addr)
use sock
#endif
preparesocket sock = setSocketOption sock ReuseAddr 1