Skip to content

Commit

Permalink
Merge pull request #6 from naushadh/relax-bound-network
Browse files Browse the repository at this point in the history
Add support for `network-3.0.0.0`.
  • Loading branch information
winterland1989 authored Jan 21, 2019
2 parents 850ef20 + 0de9c9d commit 8728acf
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ install:
- travis_retry cabal update
- cabal install --enable-tests --enable-benchmarks
- cd ./tcp-streams-openssl
- cabal install --only-dependencies --enable-tests --enable-benchmarks
- cabal install --only-dependencies --enable-tests --enable-benchmarks --force-reinstalls
- cd ../

# Here starts the actual work to be performed for the package under test; any command which exits with a non-zero exit code causes the build to fail.
Expand Down
5 changes: 5 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Revision history for tcp-streams

## 1.0.1.1

* Fix [stackage#4312](https://github.com/commercialhaskell/stackage/issues/4312): Relax version bound for `network`.


## 1.0.1.0

* Update test cert(the old one just expired).
Expand Down
12 changes: 10 additions & 2 deletions System/IO/Streams/TCP.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE CPP #-}

-- | This module provides convenience functions for interfacing raw tcp.
--
Expand Down Expand Up @@ -36,6 +37,13 @@ import qualified Network.Socket.ByteString.Lazy as NL
import qualified System.IO.Streams as S
import Foreign.Storable (sizeOf)

addrAny :: N.HostAddress
#if MIN_VERSION_network(2,7,0)
addrAny = N.tupleToHostAddress (0,0,0,0)
#else
addrAny = N.iNADDR_ANY
#endif

-- | Type alias for tcp connection.
--
-- Normally you shouldn't use 'N.Socket' in 'connExtraInfo' directly, this field is
Expand Down Expand Up @@ -145,11 +153,11 @@ bindAndListenWith :: (N.Socket -> IO ()) -- ^ set socket options before binding
-> Int -- ^ connection limit
-> N.PortNumber -- ^ port number
-> IO N.Socket
bindAndListenWith f maxc port = do
bindAndListenWith f maxc port =
E.bracketOnError (N.socket N.AF_INET N.Stream 0)
N.close
(\sock -> do f sock
N.bind sock (N.SockAddrInet port N.iNADDR_ANY)
N.bind sock (N.SockAddrInet port addrAny)
N.listen sock maxc
return sock
)
Expand Down
4 changes: 2 additions & 2 deletions tcp-streams.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: tcp-streams
version: 1.0.1.0
version: 1.0.1.1
synopsis: One stop solution for tcp client and server with tls support.
description: One stop solution for tcp client and server with tls support.
license: BSD3
Expand Down Expand Up @@ -33,7 +33,7 @@ library
other-modules: Paths_tcp_streams
-- other-extensions:
build-depends: base >=4.7 && < 5.0
, network >=2.3 && < 3.0
, network >=2.3 && < 4.0
, bytestring >= 0.10.2.0
, io-streams >= 1.2 && < 2.0
, tls >= 1.3 && < 2.0
Expand Down

0 comments on commit 8728acf

Please sign in to comment.