7 module Network.HTTP.Lucu.SocketLike
11 import qualified Network.Socket as So
12 import Network.HTTP.Lucu.HandleLike
13 import qualified OpenSSL.Session as SSL
14 import Prelude.Unicode
15 import qualified System.IO as I
17 class (HandleLike (Handle s)) ⇒ SocketLike s where
19 accept ∷ s → IO (Handle s, So.SockAddr)
20 socketPort ∷ s → IO So.PortNumber
22 instance SocketLike So.Socket where
23 type Handle So.Socket = I.Handle
26 = do (soPeer, addr) ← So.accept soSelf
27 hPeer ← So.socketToHandle soPeer I.ReadWriteMode
30 socketPort = So.socketPort
32 instance SocketLike (SSL.SSLContext, So.Socket) where
33 type Handle (SSL.SSLContext, So.Socket) = SSL.SSL
36 = do (soPeer, addr) ← So.accept soSelf
37 ssl ← SSL.connection ctx soPeer
41 socketPort = So.socketPort ∘ snd