3 dial, announce, listen, accept, reject, netmkaddr, dialparse \- make and break network connections
10 int dial(char *addr, char *local, char *dir, int *cfdp)
13 int announce(char *addr, char *dir)
16 int listen(char *dir, char *newdir)
19 int accept(int ctl, char *dir)
22 int reject(int ctl, char *dir, char *cause)
25 char* netmkaddr(char *addr, char *defnet, char *defservice)
28 .\" void setnetmtpt(char *to, int tolen, char *from)
31 .\" NetConnInfo* getnetconninfo(char *conndir, int fd)
34 .\" void freenetconninfo(NetConnINfo*)
37 int dialparse(char *addr, char **net, char **unix,
40 u32int *host, int *port)
44 is a network address of the form
45 .IB network ! netaddr ! service\f1,
46 .IB network ! netaddr\f1,
57 is a free variable that stands for any network in common
58 between the source and the host
61 can be a host name, a domain name, or a network address.
62 .\" or a meta-name of the form
63 .\" .BI $ attribute\f1,
67 .\" from the value-attribute pair
68 .\" .IB attribute = value
69 .\" most closely associated with the source host in the
70 .\" network data base (see
75 argument is a path name to a
77 that has files for accessing the connection.
78 To keep the same function signatures,
79 the Unix port of these routines uses strings of the form
81 instead of line directory paths.
82 These strings should be treated as opaque data and ignored.
85 makes a call to destination
87 on a multiplexed network.
93 will try in succession all
94 networks in common between source and destination
95 until a call succeeds.
96 It returns a file descriptor open for reading and writing the
98 file in the line directory.
101 file in the line directory contains the address called.
102 .\" If the network allows the local address to be set,
103 .\" as is the case with UDP and TCP port numbers, and
105 .\" is non-zero, the local address will be set to
113 are not supported and must be zero.
118 are the complements of
121 establishes a network
122 name to which calls can be made.
131 used in announce may be a local address or an asterisk,
132 to indicate all local addresses, e.g.
136 routine takes as its first argument the
140 When a call is received,
144 file for the line the call was received on.
147 to the path name of the new line directory.
149 accepts a call received by
153 refuses the call because of
156 returns a file descriptor for the data file opened
160 makes an address suitable for dialing or announcing.
161 It takes an address along with a default network and service to use
162 if they are not specified in the address.
163 It returns a pointer to static data holding the actual address to use.
166 parses a network address as described above
167 into a network name, a Unix domain socket address,
168 an IPv4 host address, and an IPv4 port number.
170 .\" .I Getnetconninfo
171 .\" returns a structure containing information about a
172 .\" network connection. The structure is:
174 .\" typedef struct NetConnInfo NetConnInfo;
175 .\" struct NetConnInfo
177 .\" char *dir; /* connection directory */
178 .\" char *root; /* network root */
179 .\" char *spec; /* binding spec */
180 .\" char *lsys; /* local system */
181 .\" char *lserv; /* local service */
182 .\" char *rsys; /* remote system */
183 .\" char *rserv; /* remote service */
187 .\" The information is obtained from the connection directory,
191 .\" is nil, the directory is obtained by performing
195 .\" .I Getnetconninfo
196 .\" returns either a completely specified structure, or
197 .\" nil if either the structure can't be allocated or the
198 .\" network directory can't be determined.
201 .\" .IR freenetconninfo .
204 .\" copies the name of the network mount point into
209 .\" It exists to merge two pre-existing conventions for specifying
211 .\" Commands that take a network mount point as a parameter
218 .\" .IR ipconfig (8))
225 .\" the mount point is set to the default,
229 .\" points to a string starting with a slash,
230 .\" the mount point is that path.
231 .\" Otherwise, the mount point is the string pointed to by
233 .\" appended to the string
235 .\" The last form is obsolete and is should be avoided.
236 .\" It exists only to aid in conversion.
238 Make a call and return an open file descriptor to
239 use for communications:
242 int callkremvax(void)
244 return dial("kremvax", 0, 0, 0);
248 Connect to a Unix socket served by
254 return dial("unix!/tmp/ns.ken.:0/acme", 0, 0, 0);
261 loop forever receiving calls and echoing back
262 to the caller anything sent:
269 char adir[40], ldir[40];
273 acfd = announce("tcp!*!7", adir);
277 /* listen for a call */
278 lcfd = listen(adir, ldir);
281 /* fork a process to echo */
288 /* accept the call and open the data file */
289 dfd = accept(lcfd, ldir);
294 while((n = read(dfd, buf, sizeof(buf))) > 0)
305 .B \*9/src/lib9/dial.c
307 .B \*9/src/lib9/announce.c
309 .B \*9/src/lib9/_p9dialparse.c
315 return \-1 if they fail.
317 To avoid name conflicts with the underlying system,
324 are preprocessor macros defined as