~/bend-docscommunity

net.bend relies on unsafe/foreign

raw source on the hub · import 0xd6fc55bf65b187fec4175f80d08c165a/net.bend as Net

Net: connections by host name that may be TLS, read with a deadline (net.c, native only). A connection is a Socket; after Net.tls, Net.send, Net.poll and Net.close go through the TLS session.

1 import
import Base

Effects (foreign code)

effect Net.connect source · line 7 · raw

@host:String -> @port:U32 -> IO(Result<&1, &1, Pair(U32, String), Socket>)

A host (name or IP) and port; tries every address it resolves to.

foreign: net.c, net.js

effect Net.tls source · line 15 · raw

@sock:Socket -> @host:String -> @cafile:String -> @cert:String -> @key:String -> IO(Pair(Socket, Result<&1, &1, Pair(U32, String), Unit>))

A verified TLS 1.2+ session on the socket, for host; cafile "" trusts the system's certificate store; cert and key ("" for none) are PEM files with this side's certificate, for a server that asks for one.

foreign: net.c, net.js

effect Net.send source · line 20 · raw

@sock:Socket -> @data:List<&2, U32> -> IO(Pair(Socket, Result<&1, &1, Pair(U32, String), Unit>))

foreign: net.c, net.js

effect Net.poll source · line 26 · raw

@sock:Socket -> @max:U32 -> @ms:U32 -> IO(Pair(Socket, Result<&1, &1, Pair(U32, String), Maybe<&1, List<&2, U32>>>))

Up to max bytes; Some{[]} when the peer closed, None{} after ms.

foreign: net.c, net.js

effect Net.close source · line 31 · raw

@sock:Socket -> IO(Unit)

foreign: net.c, net.js