Blob
1 .TH VENTI-SERVER 32 .SH NAME3 vtsrvhello, vtlisten, vtgetreq, vtrespond \- Venti server4 .SH SYNOPSIS5 .PP6 .ft L7 #include <u.h>8 .br9 #include <libc.h>10 .br11 #include <venti.h>12 .ta +\w'\fLVtReq* 'u13 .PP14 .ft L15 .nf16 typedef struct VtReq17 {18 VtFcall tx;19 VtFcall rx;20 ...21 } VtReq;22 .PP23 .B24 int vtsrvhello(VtConn *z)25 .PP26 .B27 VtSrv* vtlisten(char *addr)28 .PP29 .B30 VtReq* vtgetreq(VtSrv *srv)31 .PP32 .B33 void vtrespond(VtReq *req)34 .SH DESCRIPTION35 These routines execute the server side of the36 .IR venti (7)37 protocol.38 .PP39 .I Vtsrvhello40 executes the server side of the initial41 .B hello42 transaction.43 It sets44 .IB z -> uid45 with the user name claimed by the other side.46 Each new connection must be initialized by running47 .I vtversion48 and then49 .IR vtsrvhello .50 The framework below takes care of this detail automatically;51 .I vtsrvhello52 is provided for programs that do not use the functions below.53 .PP54 .IR Vtlisten ,55 .IR vtgetreq ,56 and57 .I vtrespond58 provide a simple framework for writing Venti servers.59 .PP60 .I Vtlisten61 announces at the network address62 .IR addr ,63 returning a fresh64 .B VtSrv65 structure representing the service.66 .PP67 .I Vtgetreq68 waits for and returns69 the next70 .BR read ,71 .BR write ,72 .BR sync ,73 or74 .B ping75 request from any client connected to76 the service77 .IR srv .78 .B Hello79 and80 .B goodbye81 messages are handled internally and not returned to the client.82 The interface does not distinguish between the83 different clients that may be connected at any given time.84 The request can be found in the85 .I tx86 field of the returned87 .BR VtReq .88 .PP89 Once a request has been served and a response stored in90 .IB r ->rx \fR,91 the server should call92 .IR vtrespond93 to send the response to the client.94 .I Vtrespond95 frees the structure96 .I r97 as well as the packets98 .IB r ->tx.data99 and100 .IB r ->rx.data \fR.101 .SH EXAMPLE102 .B \*9/src/venti/cmd103 contains two simple Venti servers104 .B ro.c105 and106 .B devnull.c107 written using these routines.108 .I Ro109 is a read-only Venti proxy (it rejects110 .B write111 requests).112 .I Devnull113 is a write-only Venti server: it discards all114 blocks written to it and returns error on all reads.115 .SH SOURCE116 .B \*9/src/libventi117 .SH SEE ALSO118 .IR venti (1),119 .IR venti (3),120 .IR venti-conn (3),121 .IR venti-packet (3)