Skip to content

Commit f5e5940

Browse files
Adoptions for socket-0.8.0.0
1 parent bd7d21d commit f5e5940

File tree

7 files changed

+38
-33
lines changed

7 files changed

+38
-33
lines changed

platform/linux/System/Socket/Family/Unix/Platform.hsc

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import Data.ByteString (ByteString)
2222
import Data.ByteString.Unsafe (unsafeUseAsCStringLen)
2323
import qualified Data.ByteString as B
2424

25-
import System.Socket (SocketAddress)
25+
import System.Socket (SocketAddress, Family(..))
2626
import System.Socket.Family.Unix.Internal (Unix)
2727

2828
#include "hs_socket.h"
@@ -31,16 +31,19 @@ import System.Socket.Family.Unix.Internal (Unix)
3131
#let alignment t = "%lu", (unsigned long)offsetof(struct {char x__; t (y__); }, y__)
3232
#endif
3333

34-
-- | A Unix socket address
35-
data instance SocketAddress Unix
36-
-- | Address is connected to a filesystem pathname. When used to bind
37-
-- a socket file with this name is created in the file system.
38-
= SocketAddressUnixPath ByteString
39-
-- | Address is in abstract namespace which is a Linux-specific feature
40-
-- that allows us to bind a UNIX domain socket to a name without that
41-
-- name being created in the file system.
42-
| SocketAddressUnixAbstract ByteString
43-
deriving (Eq, Show)
34+
instance Family Unix where
35+
familyNumber _ = (#const AF_UNIX)
36+
37+
-- | A Unix socket address
38+
data SocketAddress Unix
39+
-- | Address is connected to a filesystem pathname. When used to bind
40+
-- a socket file with this name is created in the file system.
41+
= SocketAddressUnixPath ByteString
42+
-- | Address is in abstract namespace which is a Linux-specific feature
43+
-- that allows us to bind a UNIX domain socket to a name without that
44+
-- name being created in the file system.
45+
| SocketAddressUnixAbstract ByteString
46+
deriving (Eq, Show)
4447

4548
-- | The maximal length of a address path.
4649
-- SUSv3 doesn’t specify the size of the sun_path field. Early BSD
@@ -97,3 +100,4 @@ instance Storable (SocketAddress Unix) where
97100
where
98101
sun_family = (#ptr struct sockaddr_un, sun_family)
99102
sun_path = (#ptr struct sockaddr_un, sun_path)
103+

platform/unix/System/Socket/Family/Unix/Platform.hsc

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import Data.ByteString (ByteString)
2121
import Data.ByteString.Unsafe (unsafeUseAsCStringLen)
2222
import qualified Data.ByteString as B
2323

24-
import System.Socket (SocketAddress)
24+
import System.Socket (SocketAddress, Family(..))
2525
import System.Socket.Family.Unix.Internal (Unix)
2626

2727
#include "hs_socket.h"
@@ -30,12 +30,15 @@ import System.Socket.Family.Unix.Internal (Unix)
3030
#let alignment t = "%lu", (unsigned long)offsetof(struct {char x__; t (y__); }, y__)
3131
#endif
3232

33-
-- | A Unix socket address
34-
data instance SocketAddress Unix
35-
-- | Address is connected to a filesystem pathname. When used to bind
36-
-- a socket file with this name is created in the file system.
37-
= SocketAddressUnixPath ByteString
38-
deriving (Eq, Show)
33+
instance Family Unix where
34+
familyNumber _ = (#const AF_UNIX)
35+
36+
-- | A Unix socket address
37+
data SocketAddress Unix
38+
-- | Address is connected to a filesystem pathname. When used to bind
39+
-- a socket file with this name is created in the file system.
40+
= SocketAddressUnixPath ByteString
41+
deriving (Eq, Show)
3942

4043
-- | The maximal length of a address path.
4144
-- SUSv3 doesn’t specify the size of the sun_path field. Early BSD

socket-unix.cabal

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ library
2424
other-modules: System.Socket.Family.Unix.Internal
2525
System.Socket.Family.Unix.Platform
2626
build-depends: base >= 4.7 && < 5
27-
, socket >= 0.6.0.0 && < 0.8.0.0
27+
, socket >= 0.8.0.0 && < 0.9.0.0
2828
, bytestring >= 0.10.0.0 && < 0.11
2929

3030
ghc-options: -Wall -O2
@@ -41,7 +41,7 @@ test-suite default
4141
other-modules: Internal
4242
Platform
4343
build-depends: base >= 4.7 && < 5
44-
, socket >= 0.6.0.0 && < 0.8.0.0
44+
, socket >= 0.8.0.0 && < 0.9.0.0
4545
, socket-unix
4646
, tasty >= 0.11 && < 0.12
4747
, tasty-hunit >= 0.9 && < 0.10
@@ -61,7 +61,7 @@ test-suite threaded
6161
other-modules: Internal
6262
Platform
6363
build-depends: base >= 4.7 && < 5
64-
, socket >= 0.6.0.0 && < 0.8.0.0
64+
, socket >= 0.8.0.0 && < 0.9.0.0
6565
, socket-unix
6666
, tasty >= 0.11 && < 0.12
6767
, tasty-hunit >= 0.9 && < 0.10

src/System/Socket/Family/Unix/Internal.hsc

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module System.Socket.Family.Unix.Internal
88
, eNoEntry
99
) where
1010

11-
import System.Socket (Family(..), Protocol(..), SocketException(..))
11+
import System.Socket (SocketException(..))
1212

1313
#include "hs_socket.h"
1414

@@ -20,11 +20,6 @@ import System.Socket (Family(..), Protocol(..), SocketException(..))
2020
-- (https://en.wikipedia.org/wiki/Unix_domain_socket)
2121
data Unix
2222

23-
instance Family Unix where
24-
familyNumber _ = (#const AF_UNIX)
25-
26-
instance Protocol Unix where
27-
protocolNumber _ = 0
2823

2924
-- | > SocketException "No such file or directory"
3025
eNoEntry :: SocketException

stack-ghc7.10.3.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ resolver: lts-6.27
22

33
packages:
44
- '.'
5-
extra-deps: []
5+
extra-deps:
6+
- socket-0.8.0.0
67

78
# Override default flag values for local packages and extra-deps
89
flags: {}

stack-ghc8.0.2.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ resolver: lts-8.0
22

33
packages:
44
- '.'
5-
extra-deps: []
5+
extra-deps:
6+
- socket-0.8.0.0
67

78
# Override default flag values for local packages and extra-deps
89
flags: {}

test/Internal.hs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import Test.Tasty.HUnit
1414
import System.Socket
1515
import System.Socket.Type.Stream
1616
import System.Socket.Type.Datagram
17+
import System.Socket.Protocol.Default
1718
import System.Socket.Family.Unix
1819

1920
groupUnixPathname :: TestTree
@@ -68,15 +69,15 @@ abstractPath = "/tmp/uth4Aechiereejae.socket"
6869
clientAbstractPath :: ByteString
6970
clientAbstractPath = "/tmp/FieNg4shamo4Thie.socket"
7071

71-
unixSocketStream :: IO (Socket Unix Stream Unix)
72+
unixSocketStream :: IO (Socket Unix Stream Default)
7273
unixSocketStream = socket
7374

74-
unixSocketDatagram :: IO (Socket Unix Datagram Unix)
75+
unixSocketDatagram :: IO (Socket Unix Datagram Default)
7576
unixSocketDatagram = socket
7677

7778
testServerClientStream
7879
:: SocketAddress Unix
79-
-> (Socket Unix Stream Unix, Socket Unix Stream Unix)
80+
-> (Socket Unix Stream Default, Socket Unix Stream Default)
8081
-> IO ()
8182
testServerClientStream addr (server, client) = do
8283
bind server addr
@@ -97,7 +98,7 @@ testServerClientStream addr (server, client) = do
9798
testServerClientDatagram
9899
:: SocketAddress Unix
99100
-> SocketAddress Unix
100-
-> (Socket Unix Datagram Unix, Socket Unix Datagram Unix)
101+
-> (Socket Unix Datagram Default, Socket Unix Datagram Default)
101102
-> IO ()
102103
testServerClientDatagram sAddr cAddr (server, client) = do
103104
bind server sAddr

0 commit comments

Comments
 (0)