wire.bend relies on unsafe/foreign
raw source on the hub · import 0x969a778eb4fb2d6461f05616e7314226/wire.bend as Wire
Byte-exact TCP, UDP, and TLS sockets.
1 import
import Base
Effects (foreign code)
effect connect source · line 10 · raw
@host:String -> @port:U32 -> @ms:U32 -> IO(Result<&1, &1, Pair(U32, String), Socket>)
TCP connect to an IPv4 address, with a deadline.
foreign: effs/wire.c, effs/wire.js
effect recv source · line 15 · raw
@sock:Socket -> @max:U32 -> @ms:U32 -> IO(Pair(Socket, Result<&1, &1, Pair(U32, String), String>))
foreign: effs/wire.c, effs/wire.js
effect send source · line 20 · raw
@sock:Socket -> @data:String -> IO(Pair(Socket, Result<&1, &1, Pair(U32, String), Unit>))
foreign: effs/wire.c, effs/wire.js
effect recv_from source · line 25 · raw
@sock:Socket -> @max:U32 -> @ms:U32 -> IO(Pair(Socket, Result<&1, &1, Pair(U32, String), Pair(String, Pair(U32, String))>))
foreign: effs/wire.c, effs/wire.js
effect send_to source · line 30 · raw
@sock:Socket -> @host:String -> @port:U32 -> @data:String -> IO(Pair(Socket, Result<&1, &1, Pair(U32, String), Unit>))
foreign: effs/wire.c, effs/wire.js
effect tls.connect source · line 37 · raw
@sock:Socket -> @host:String -> @ms:U32 -> IO(Pair(Socket, Result<&1, &1, Pair(U32, String), Unit>))
TLS over a connected TCP socket (OpenSSL 3, loaded at run time; BEND_LIBSSL overrides its path). The certificate chain and host name are always checked.
foreign: effs/wire.c, effs/wire.js
effect tls.send source · line 42 · raw
@sock:Socket -> @data:String -> IO(Pair(Socket, Result<&1, &1, Pair(U32, String), Unit>))
foreign: effs/wire.c, effs/wire.js
effect tls.recv source · line 48 · raw
@sock:Socket -> @max:U32 -> @ms:U32 -> IO(Pair(Socket, Result<&1, &1, Pair(U32, String), String>))
"" once the peer sends close_notify. A bare EOF is an error.
foreign: effs/wire.c, effs/wire.js
effect tls.close source · line 54 · raw
@sock:Socket -> IO(Unit)
Ends the TLS session and closes the socket.
foreign: effs/wire.c, effs/wire.js
effect recv.words source · line 60 · raw
@sock:Socket -> @max:U32 -> @ms:U32 -> IO(Pair(Socket, Result<&1, &1, Pair(U32, String), Pair(U32, Array<U32>)>))
The .words forms move (len, words): bytes packed four to a U32, laid out as bytes/bytes.bend packs them, so no String cell is made per byte.
foreign: effs/wire.c, effs/wire.js
effect send.words source · line 66 · raw
@sock:Socket -> @len:U32 -> @words:Array<U32> -> IO(Pair(Socket, Result<&1, &1, Pair(U32, String), Unit>))
len past the end of words fails with EINVAL.
foreign: effs/wire.c, effs/wire.js
effect tls.recv.words source · line 72 · raw
@sock:Socket -> @max:U32 -> @ms:U32 -> IO(Pair(Socket, Result<&1, &1, Pair(U32, String), Pair(U32, Array<U32>)>))
len 0 once the peer sends close_notify.
foreign: effs/wire.c, effs/wire.js
effect tls.send.words source · line 77 · raw
@sock:Socket -> @len:U32 -> @words:Array<U32> -> IO(Pair(Socket, Result<&1, &1, Pair(U32, String), Unit>))
foreign: effs/wire.c, effs/wire.js