@@ -8,50 +8,40 @@ module Data.Streaming.Network
88    , HostPreference 
99    , Message  (.. )
1010    , AppData 
11- #if  !WINDOWS
1211    , ServerSettingsUnix 
1312    , ClientSettingsUnix 
1413    , AppDataUnix 
15- #endif 
1614      --  ** Smart constructors
1715    , serverSettingsTCP 
1816    , serverSettingsTCPSocket 
1917    , clientSettingsTCP 
2018    , serverSettingsUDP 
2119    , clientSettingsUDP 
22- #if  !WINDOWS
2320    , serverSettingsUnix 
2421    , clientSettingsUnix 
25- #endif 
2622    , message 
2723      --  ** Classes
2824    , HasPort  (.. )
2925    , HasAfterBind  (.. )
3026    , HasReadWrite  (.. )
3127    , HasReadBufferSize  (.. )
32- #if  !WINDOWS
3328    , HasPath  (.. )
34- #endif 
3529      --  ** Setters
3630    , setPort 
3731    , setHost 
3832    , setAddrFamily 
3933    , setAfterBind 
4034    , setNeedLocalAddr 
4135    , setReadBufferSize 
42- #if  !WINDOWS
4336    , setPath 
44- #endif 
4537      --  ** Getters
4638    , getPort 
4739    , getHost 
4840    , getAddrFamily 
4941    , getAfterBind 
5042    , getNeedLocalAddr 
5143    , getReadBufferSize 
52- #if  !WINDOWS
5344    , getPath 
54- #endif 
5545    , appRead 
5646    , appWrite 
5747    , appSockAddr 
@@ -82,13 +72,11 @@ module Data.Streaming.Network
8272    , bindPortUDP 
8373    , bindRandomPortUDP 
8474    , getSocketUDP 
85- #if  !WINDOWS
8675      --  ** Unix
8776    , bindPath 
8877    , getSocketUnix 
8978    , runUnixServer 
9079    , runUnixClient 
91- #endif 
9280    ) where 
9381
9482import  qualified  Network.Socket  as  NS 
@@ -265,7 +253,6 @@ defaultReadBufferSize :: Int
265253defaultReadBufferSize =  unsafeDupablePerformIO $ 
266254  bracket (NS. socket NS. AF_INETNS. Stream0 ) NS. close (\ sock ->  NS. getSocketOption sock NS. RecvBuffer
267255
268- #if  !WINDOWS
269256--  |  Attempt to connect to the given Unix domain socket path. 
270257getSocketUnix  ::  FilePath ->  IO Socket 
271258getSocketUnix path =  do 
@@ -317,7 +304,6 @@ clientSettingsUnix path = ClientSettingsUnix
317304    { clientPath =  path
318305    , clientReadBufferSizeUnix =  defaultReadBufferSize
319306    }
320- #endif 
321307
322308#if  defined(__GLASGOW_HASKELL__) && WINDOWS
323309--  Socket recv and accept calls on Windows platform cannot be interrupted when compiled with -threaded.
@@ -495,7 +481,6 @@ setAddrFamily af cs = cs { clientAddrFamily = af }
495481getAddrFamily  ::  ClientSettings  ->  NS. Family
496482getAddrFamily =  clientAddrFamily
497483
498- #if  !WINDOWS
499484class  HasPath  a  where 
500485    pathLens  ::  Functor f  =>  (FilePath ->  f  FilePath ->  a  ->  f  a 
501486instance  HasPath  ServerSettingsUnix  where 
@@ -508,7 +493,6 @@ getPath = getConstant . pathLens Constant
508493
509494setPath  ::  HasPath  a  =>  FilePath ->  a  ->  a 
510495setPath p =  runIdentity .  pathLens (const  (Identity  p))
511- #endif 
512496
513497setNeedLocalAddr  ::  Bool ->  ServerSettings  ->  ServerSettings 
514498setNeedLocalAddr x y =  y { serverNeedLocalAddr =  x }
@@ -520,10 +504,8 @@ class HasAfterBind a where
520504    afterBindLens  ::  Functor f  =>  ((Socket  ->  IO () ) ->  f  (Socket  ->  IO () )) ->  a  ->  f  a 
521505instance  HasAfterBind  ServerSettings  where 
522506    afterBindLens f ss =  fmap  (\ p ->  ss { serverAfterBind =  p }) (f (serverAfterBind ss))
523- #if  !WINDOWS
524507instance  HasAfterBind  ServerSettingsUnix  where 
525508    afterBindLens f ss =  fmap  (\ p ->  ss { serverAfterBindUnix =  p }) (f (serverAfterBindUnix ss))
526- #endif 
527509
528510getAfterBind  ::  HasAfterBind  a  =>  a  ->  (Socket  ->  IO () )
529511getAfterBind =  getConstant .  afterBindLens Constant 
@@ -540,14 +522,12 @@ instance HasReadBufferSize ServerSettings where
540522--  |  Since 0.1.13 
541523instance  HasReadBufferSize  ClientSettings  where 
542524    readBufferSizeLens f cs =  fmap  (\ p ->  cs { clientReadBufferSize =  p }) (f (clientReadBufferSize cs))
543- #if  !WINDOWS
544525--  |  Since 0.1.13 
545526instance  HasReadBufferSize  ServerSettingsUnix  where 
546527    readBufferSizeLens f ss =  fmap  (\ p ->  ss { serverReadBufferSizeUnix =  p }) (f (serverReadBufferSizeUnix ss))
547528--  |  Since 0.1.14 
548529instance  HasReadBufferSize  ClientSettingsUnix  where 
549530    readBufferSizeLens f ss =  fmap  (\ p ->  ss { clientReadBufferSizeUnix =  p }) (f (clientReadBufferSizeUnix ss))
550- #endif 
551531
552532--  |  Get buffer size used when reading from socket. 
553533-- 
@@ -640,19 +620,16 @@ class HasReadWrite a where
640620instance  HasReadWrite  AppData  where 
641621    readLens f a =  fmap  (\ x ->  a { appRead' =  x }) (f (appRead' a))
642622    writeLens f a =  fmap  (\ x ->  a { appWrite' =  x }) (f (appWrite' a))
643- #if  !WINDOWS
644623instance  HasReadWrite  AppDataUnix  where 
645624    readLens f a =  fmap  (\ x ->  a { appReadUnix =  x }) (f (appReadUnix a))
646625    writeLens f a =  fmap  (\ x ->  a { appWriteUnix =  x }) (f (appWriteUnix a))
647- #endif 
648626
649627appRead  ::  HasReadWrite  a  =>  a  ->  IO ByteString 
650628appRead =  getConstant .  readLens Constant 
651629
652630appWrite  ::  HasReadWrite  a  =>  a  ->  ByteString  ->  IO () 
653631appWrite =  getConstant .  writeLens Constant 
654632
655- #if  !WINDOWS
656633--  |  Run an @Application@ with the given settings. This function will create a 
657634--  new listening socket, accept connections on it, and spawn a new thread for 
658635--  each connection. 
@@ -686,4 +663,3 @@ runUnixClient (ClientSettingsUnix path readBufferSize) app = E.bracket
686663        { appReadUnix =  safeRecv sock readBufferSize
687664        , appWriteUnix =  sendAll sock
688665        })
689- #endif 
0 commit comments