122 lines · 2.1 KB · Text
RawDownload
.TH VENTI-SERVER 2.SH NAMEvtsrvhello, vtlisten, vtgetreq, vtrespond \- Venti server.SH SYNOPSIS.PP.ft L#include <u.h>.br#include <libc.h>.br#include <venti.h>.ta +\w'\fLVtReq* 'u.PP.ft L.nftypedef struct VtReq{	VtFcall tx;	VtFcall rx;	...} VtReq;.PP.Bint	vtsrvhello(VtConn *z).PP.BVtSrv*	vtlisten(char *addr).PP.BVtReq*	vtgetreq(VtSrv *srv).PP.Bvoid	vtrespond(VtReq *req).SH DESCRIPTIONThese routines execute the server side of the.IR venti (6)protocol..PP.I Vtsrvhelloexecutes the server side of the initial.B hellotransaction.It sets.IB z -> uidwith the user name claimed by the other side.Each new connection must be initialized by running.I vtversionand then.IR vtsrvhello .The framework below takes care of this detail automatically;.I vtsrvhellois provided for programs that do not use the functions below..PP.IR Vtlisten ,.IR vtgetreq ,and.I vtrespondprovide a simple framework for writing Venti servers..PP.I Vtlistenannounces at the network address.IR addr ,returning a fresh.B VtSrvstructure representing the service..PP.I Vtgetreqwaits for and returnsthe next .BR read ,.BR write ,.BR sync ,or.B pingrequest from any client connected tothe service.IR srv ..B Helloand.B goodbyemessages are handled internally and not returned to the client.The interface does not distinguish between thedifferent clients that may be connected at any given time.The request can be found in the.I txfield of the returned.BR VtReq ..PPOnce a request has been served and a response stored in.IB r ->rx \fR,the server should call.IR vtrespondto send the response to the client..I Vtrespondfrees the structure.I ras well as the packets.IB r ->tx.dataand.IB r ->rx.data \fR..SH EXAMPLE.B /sys/src/cmd/venticontains two simple Venti servers .B ro.cand.B devnull.cwritten using these routines..I Rois a read-only Venti proxy (it rejects.B writerequests)..I Devnullis a dangerous write-only Venti server: it discards allblocks written to it and returns error on all reads..SH SOURCE.B /sys/src/libventi.SH SEE ALSO.IR venti (2),.IR venti-conn (2),.IR venti-packet (2),.IR venti (6),.IR venti (8)