2020-05-18 15:59:07 +03:00
|
|
|
module Control.App.Network
|
|
|
|
|
|
|
|
import Control.App
|
|
|
|
import Control.App.Network.Data
|
|
|
|
|
|
|
|
data SocketState = Ready | Bound | Listening | Open | Closed
|
|
|
|
|
|
|
|
data Socket : SocketState -> Type where
|
|
|
|
MkSocket : Int -> Socket s
|
|
|
|
|
|
|
|
data NetworkError = Foo
|
|
|
|
|
|
|
|
interface Has [Exception NetworkError] e => Network e where
|
|
|
|
newSocket : (1 p : (1 s : Socket Ready) -> App e a) -> App e a
|
|
|
|
done : (1 s : Socket Closed) -> App e ()
|
|
|
|
|
2021-01-16 10:03:45 +03:00
|
|
|
bind : (1 sock : Socket Ready) ->
|
|
|
|
(addr : Maybe SocketAddress) -> (port : Port) ->
|
2020-05-18 15:59:07 +03:00
|
|
|
Either NetworkError (Socket Bound)
|
|
|
|
|
|
|
|
{-
|
|
|
|
connect : (sock : Socket) -> (addr : SocketAddress) -> (port : Port) -> IO ResultCode
|
|
|
|
listen : (sock : Socket) -> IO Int
|
|
|
|
accept : (sock : Socket) -> IO (Either SocketError (Socket, SocketAddress))
|
|
|
|
send : (sock : Socket) -> (msg : String) -> IO (Either SocketError ResultCode)
|
|
|
|
recv : (sock : Socket) -> (len : ByteLength) -> IO (Either SocketError (String, ResultCode))
|
|
|
|
close : Socket -> IO ()
|
|
|
|
-}
|