Commit 795d6235 authored by Mart Lubbers's avatar Mart Lubbers Committed by Mart Lubbers

fix socket examples for new api

parent 2610c869
......@@ -9,7 +9,7 @@ import System.Socket.Ipv4
Start :: *World -> (MaybeOSError String, *World)
Start w
= case socket ST_Stream 0 w of
= case socket ST_Stream w of
(Error e, w) = (Error e, w)
(Ok sockfd, w)
#! (merr, sockfd) = connect {sin_port=8124,sin_addr=Just (fromString "127.0.0.1")} sockfd
......
......@@ -10,7 +10,7 @@ import System.Socket.Ipv4
Start :: *World -> (MaybeOSError (), *World)
Start w
= case socket ST_Stream 0 w of
= case socket ST_Stream w of
(Error e, w) = (Error e, w)
(Ok sockfd, w)
#! (merr, sockfd) = bind {sin_port=8124,sin_addr=Nothing} sockfd
......
......@@ -6,7 +6,7 @@ from System._Pointer import :: Pointer(..)
from System._Socket import :: Socket
from System.OSError import :: MaybeOSError, :: OSError, :: OSErrorMessage, :: OSErrorCode
:: SocketType = ST_Stream | ST_DGram
:: SocketType = SocketStream | SocketDataGram
:: SendFlag = SendFlagOob | SendFlagDontRoute
:: RecvFlag = RecvFlagOob | RecvFlagWaitAll | RecvFlagPeek
instance toInt SocketType, SendFlag, RecvFlag
......@@ -18,11 +18,10 @@ class SocketAddress sa where
sa_domain :: !sa -> Int
sa_null :: sa
/*
* Register a socket with the given type
*
* @param Socket type
* @param type of communication semantics
* @param environment
* @return socket
* @return new environment
......
......@@ -5,8 +5,8 @@ import System._Socket => qualified socket, bind, listen, accept, close, connect,
import System.OSError
instance toInt SocketType where
toInt ST_Stream = SOCK_STREAM
toInt ST_DGram = SOCK_DGRAM
toInt SocketStream = SOCK_STREAM
toInt SocketDataGram = SOCK_DGRAM
instance toInt SendFlag where
toInt SendFlagOob = MSG_OOB
......
......@@ -9,7 +9,7 @@ import System.Socket => qualified socket, bind, listen, accept, close, connect,
:: *Socket a :== Int
socket :: !SocketType !Int !*env -> *(!MaybeOSError *(Socket sa), !*env) | SocketAddress sa
socket :: !SocketType !*env -> *(!MaybeOSError *(Socket sa), !*env) | SocketAddress sa
socket type w
# (sockfd, w) = socket` (sa_domain msa) (toInt type) 0 w
# (fd, sockfd) = getFd sockfd
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment