3 dial, hangup, 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, u32int *host, int *port)
41 is a network address of the form
42 .IB network ! netaddr ! service\f1,
43 .IB network ! netaddr\f1,
54 is a free variable that stands for any network in common
55 between the source and the host
58 can be a host name, a domain name, or a network address.
59 .\" or a meta-name of the form
60 .\" .BI $ attribute\f1,
64 .\" from the value-attribute pair
65 .\" .IB attribute = value
66 .\" most closely associated with the source host in the
67 .\" network data base (see
72 argument is a path name to a
74 that has files for accessing the connection.
75 To keep the same function signatures,
76 the Unix port of these routines uses strings of the form
78 instead of line directory paths.
79 These strings should be treated as opaque data and ignored.
82 makes a call to destination
84 on a multiplexed network.
90 will try in succession all
91 networks in common between source and destination
92 until a call succeeds.
93 It returns a file descriptor open for reading and writing the
95 file in the line directory.
98 file in the line directory contains the address called.
99 .\" If the network allows the local address to be set,
100 .\" as is the case with UDP and TCP port numbers, and
102 .\" is non-zero, the local address will be set to
110 are not supported and must be zero.
115 are the complements of
118 establishes a network
119 name to which calls can be made.
128 used in announce may be a local address or an asterisk,
129 to indicate all local addresses, e.g.
133 routine takes as its first argument the
137 When a call is received,
141 file for the line the call was received on.
144 to the path name of the new line directory.
146 accepts a call received by
150 refuses the call because of
153 returns a file descriptor for the data file opened
157 makes an address suitable for dialing or announcing.
158 It takes an address along with a default network and service to use
159 if they are not specified in the address.
160 It returns a pointer to static data holding the actual address to use.
163 parses a network address as described above
164 into a network name, a Unix domain socket address,
165 an IPv4 host address, and an IPv4 port number.
167 .\" .I Getnetconninfo
168 .\" returns a structure containing information about a
169 .\" network connection. The structure is:
171 .\" typedef struct NetConnInfo NetConnInfo;
172 .\" struct NetConnInfo
174 .\" char *dir; /* connection directory */
175 .\" char *root; /* network root */
176 .\" char *spec; /* binding spec */
177 .\" char *lsys; /* local system */
178 .\" char *lserv; /* local service */
179 .\" char *rsys; /* remote system */
180 .\" char *rserv; /* remote service */
184 .\" The information is obtained from the connection directory,
188 .\" is nil, the directory is obtained by performing
192 .\" .I Getnetconninfo
193 .\" returns either a completely specified structure, or
194 .\" nil if either the structure can't be allocated or the
195 .\" network directory can't be determined.
198 .\" .IR freenetconninfo .
201 .\" copies the name of the network mount point into
206 .\" It exists to merge two pre-existing conventions for specifying
208 .\" Commands that take a network mount point as a parameter
215 .\" .IR ipconfig (8))
222 .\" the mount point is set to the default,
226 .\" points to a string starting with a slash,
227 .\" the mount point is that path.
228 .\" Otherwise, the mount point is the string pointed to by
230 .\" appended to the string
232 .\" The last form is obsolete and is should be avoided.
233 .\" It exists only to aid in conversion.
235 Make a call and return an open file descriptor to
236 use for communications:
239 int callkremvax(void)
241 return dial("kremvax", 0, 0, 0);
245 Connect to a Unix socket served by
251 return dial("unix!/tmp/ns.ken.:0/acme", 0, 0, 0);
258 loop forever receiving calls and echoing back
259 to the caller anything sent:
266 char adir[40], ldir[40];
270 acfd = announce("tcp!*!7", adir);
274 /* listen for a call */
275 lcfd = listen(adir, ldir);
278 /* fork a process to echo */
285 /* accept the call and open the data file */
286 dfd = accept(lcfd, ldir);
291 while((n = read(dfd, buf, sizeof(buf))) > 0)
302 .B \*9/src/lib9/dial.c
304 .B \*9/src/lib9/announce.c
306 .B \*9/src/lib9/_p9dialparse.c
312 return \-1 if they fail.