Fix sockets and use correct address family
This commit is contained in:
parent
d275773bab
commit
9672c5fb8f
10
interp.hs
10
interp.hs
|
@ -129,10 +129,12 @@ _fclose handle@(StreamV h) = do
|
||||||
|
|
||||||
_sockopen (TupleV [StrV host, IntV port]) = do
|
_sockopen (TupleV [StrV host, IntV port]) = do
|
||||||
(handles,env) <- get
|
(handles,env) <- get
|
||||||
sock <- lift $ SO.socket SO.AF_INET SO.Stream SO.defaultProtocol
|
handle <- lift $ SO.withSocketsDo $ do
|
||||||
addr:_ <- lift $ SO.getAddrInfo Nothing (Just host) (Just $ show port)
|
addr:_ <- SO.getAddrInfo Nothing (Just host) (Just $ show port)
|
||||||
lift $ SO.connect sock (SO.addrAddress addr)
|
sock <- SO.socket (SO.addrFamily addr) SO.Stream SO.defaultProtocol
|
||||||
handle <- lift $ SO.socketToHandle sock ReadWriteMode
|
SO.connect sock (SO.addrAddress addr)
|
||||||
|
handle <- SO.socketToHandle sock ReadWriteMode
|
||||||
|
return handle
|
||||||
put (handles ++ [handle], env)
|
put (handles ++ [handle], env)
|
||||||
return . StreamV $ length handles
|
return . StreamV $ length handles
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue