3 dial, announce, listen, accept, reject, netmkaddr, getnetconninfo, freenetconninfo, 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 *dir, 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
99 .\" file in the line directory.
102 .\" file in the line directory contains the address called.
103 If the network allows the local address to be set,
104 as is the case with UDP and TCP port numbers, and
106 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.
171 returns a structure containing information about a
172 network connection. The structure is:
175 typedef struct NetConnInfo NetConnInfo;
178 char *dir; /* connection directory */
179 char *root; /* network root */
180 char *spec; /* binding spec */
181 char *lsys; /* local system */
182 char *lserv; /* local service */
183 char *rsys; /* remote system */
184 char *rserv; /* remote service */
185 char *laddr; /* local address */
186 char *raddr; /* remote address */
190 The information is obtained from the
195 is nil, from the connection file descriptor
198 returns either a completely specified structure, or
199 nil if either the structure can't be allocated or the
200 network directory can't be determined.
203 .IR freenetconninfo .
206 .\" copies the name of the network mount point into
211 .\" It exists to merge two pre-existing conventions for specifying
213 .\" Commands that take a network mount point as a parameter
220 .\" .IR ipconfig (8))
227 .\" the mount point is set to the default,
231 .\" points to a string starting with a slash,
232 .\" the mount point is that path.
233 .\" Otherwise, the mount point is the string pointed to by
235 .\" appended to the string
237 .\" The last form is obsolete and is should be avoided.
238 .\" It exists only to aid in conversion.
240 Make a call and return an open file descriptor to
241 use for communications:
244 int callkremvax(void)
246 return dial("kremvax", 0, 0, 0);
250 Connect to a Unix socket served by
256 return dial("unix!/tmp/ns.ken.:0/acme", 0, 0, 0);
263 loop forever receiving calls and echoing back
264 to the caller anything sent:
271 char adir[40], ldir[40];
275 acfd = announce("tcp!*!7", adir);
279 /* listen for a call */
280 lcfd = listen(adir, ldir);
283 /* fork a process to echo */
290 /* accept the call and open the data file */
291 dfd = accept(lcfd, ldir);
296 while((n = read(dfd, buf, sizeof(buf))) > 0)
307 .B \*9/src/lib9/dial.c
309 .B \*9/src/lib9/announce.c
311 .B \*9/src/lib9/_p9dialparse.c
313 .B \*9/src/lib9/getnetconn.c
319 return \-1 if they fail.
321 To avoid name conflicts with the underlying system,
328 are preprocessor macros defined as