VENTI-CONN(3)
π VENTI-CONN(3) π
okay so welcome to VENTI-CONN(3), straight out of the Library Functions Manual, section 3 (the library-functions section, iykyk). this is the whole Venti network-connection situation and honestly? it's giving infrastructure. let's get into it π«Ά
β¨ NAME β¨
VtConn, vtconn, vtdial, vtfreeconn, vtsend, vtrecv, vtversion, vtdebug, vthangup β all the little guys that handle Venti network connections π
π SYNOPSIS π
#include <u.h>
#include <libc.h>
#include <venti.h>
typedef struct VtConn {
int debug;
char *version;
char *uid;
char *sid;
char addr[256];
...
} VtConn;
VtConn* vtconn(int infd, int outfd)
int vtreconn(VtConn *z, int infd, int outfd)
VtConn* vtdial(char *addr)
int vtredial(VtConn *z, char *addr)
int vtversion(VtConn *z)
int vtsend(VtConn *z, Packet *p)
Packet* vtrecv(VtConn *z)
void vtrecvproc(void *z)
void vtsendproc(void *z)
void vtdebug(VtConn *z, char *fmt, ...)
void vthangup(VtConn *z)
void vtfreeconn(VtConn *z)
extern int chattyventi;/* default 0 */
like, look at all those little functions. they're a family. π§
πΈ DESCRIPTION πΈ
a VtConn structure is literally just a representation of a connection β to a Venti server when a client is using it, or to a client when a server is using it. main character struct energy honestly. π
it's got these user-visible fields, bestie, take notes:
debugβ a flag that turns on debugging prints β¨versionβ the protocol version currently in useuidβ the name of the client, and pls note it's (unverified)sidβ the name of the server, also (unverified)addrβ the network address of the remote side
vtconn initializes a fresh new connection structure using the file descriptors infd and outfd for reading and writing β and yeah, they're allowed to be the same one, no drama. π«Ά
vtdial dials up the network address you give it (peep dial(3)) and hands you back the corresponding connection. if the connection can't be established? it returns nil. sad but true π
vtversion exchanges version info with the remote side exactly like venti(7) describes. the negotiated version gets stored in z->version. slay, negotiation. π
vtsend writes a packet (check venti-packet(3)) on the connection z. pro tip: the packet p should be a formatted Venti message, like the kind vtfcallpack would return, and vtsend will add the two-byte length field (again, see venti(7)) at the beginning. β οΈ and heads up β vtsend frees p, even if there's an error. like it's gone gone. π
vtrecv reads a packet from the connection z. it's the mirror twin of vtsend: the data read from the connection must start with a two-byte length, but the packet it returns will omit them. cute. π
π¦ the whole blocking situation (important!!) π¦
by default, vtsend and vtrecv block until the packet can actually be written to or read from the network. in a threaded program (see thread(3)), that might not be the vibe you want. π¬
so here's the move: if the caller arranges for vtsendproc and vtrecvproc to run in their own procs (usually by calling proccreate), then vtsend and vtrecv will yield the proc they're running in to other threads while they're waiting on the network. teamwork fr fr. π
thevoid*argument you pass tovtsendprocandvtrecvprocmust be the connection structurez. no substitutions, bestie. π
vtdebug prints the formatted message to standard error when z->debug is set. and when it's not set? literally a no-op. nothing happens. the void. π
vthangup hangs up a connection β it closes the associated file descriptors and shuts down the send and receive procs if those were ever started. future calls to vtrecv or vtsend will return errors after this. and if you call vthangup again? no effect. it's already hung up, babe. β¨
vtfreeconn frees the connection structure, and it'll hang it up first if that's still necessary. considerate king behavior. π
and ooh β if that global variable chattyventi is set, the library prints all Venti RPCs to standard error as they're sent or received. chatty indeed. π
β SOURCE β
/src/libventi
π SEE ALSO π
venti(1), venti(3), venti-client(3), venti-packet(3), venti-server(3), venti(7)
π₯ DIAGNOSTICS π₯
- routines that return pointers return nil on error
- routines returning integers return 0 on success and -1 on error
- all routines set
errstron error
like, every single one. no cap. π«Ά
and that's the whole page!! this was VENTI-CONN(3) from the Library Functions Manual (section 3, obviously) β thanks for reading bestie, mwah πππ¦πΈβ¨
π¦ where this page comes from
- alpine 3.24: plan9port-doc 0_git20260208-r0 Β· LPL-1.02
- arch rolling: plan9port 20261021-2 Β· custom
- nixos 26.05: plan9port 0-unstable-2025-11-10
- nixos 26.05: plan9port-wayland 0-unstable-2025-11-26
- nixpkgs unstable: plan9port 0-unstable-2025-11-10
- nixpkgs unstable: plan9port-wayland 0-unstable-2025-11-26
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms