3 dial, hangup, announce, listen, accept, reject, netmkaddr, setnetmtpt, getnetconninfo, freenetconninfo \- make and break network connections
10 int dial(char *addr, char *local, char *dir, int *cfdp)
16 int announce(char *addr, char *dir)
19 int listen(char *dir, char *newdir)
22 int accept(int ctl, char *dir)
25 int reject(int ctl, char *dir, char *cause)
28 char* netmkaddr(char *addr, char *defnet, char *defservice)
31 void setnetmtpt(char *to, int tolen, char *from)
34 NetConnInfo* getnetconninfo(char *conndir, int fd)
37 void freenetconninfo(NetConnInfo*)
41 is a network address of the form
42 .IB network ! netaddr ! service\f1,
43 .IB network ! netaddr\f1,
47 is any directory listed in
52 is a free variable that stands for any network in common
53 between the source and the host
56 can be a host name, a domain name, a network address,
57 or a meta-name of the form
62 from the value-attribute pair
64 most closely associated with the source host in the
65 network data base (see
68 If a connection attempt is successful and
73 that has files for accessing the connection
76 The path name is guaranteed to be less than 40
78 One line directory exists for each possible connection.
81 file in the line directory should be used to communicate with the destination.
84 file in the line directory can be used to send commands to the line.
87 for messages that can be written to the
94 file will close the connection.
97 makes a call to destination
99 on a multiplexed network.
105 will try all addresses on networks in common between source
106 and destination until a call succeeds.
107 It returns a file descriptor open for reading and writing the
109 file in the line directory.
112 file in the line directory contains the address called.
113 If the network allows the local address to be set,
114 as is the case with UDP and TCP port numbers, and
116 is non-zero, the local address will be set to
122 is set to a file descriptor open for reading and
123 writing the control file.
126 is a means of forcing a connection to hang up without
136 are the complements of
139 establishes a network
140 name to which calls can be made.
149 used in announce may be a local address or an asterisk,
150 to indicate all local addresses, e.g.
154 routine takes as its first argument the
158 When a call is received,
162 file for the line the call was received on.
165 to the path name of the new line directory.
167 accepts a call received by
171 refuses the call because of
174 returns a file descriptor for the data file opened
178 makes an address suitable for dialing or announcing.
179 It takes an address along with a default network and service to use
180 if they are not specified in the address.
181 It returns a pointer to static data holding the actual address to use.
184 returns a structure containing information about a
185 network connection. The structure is:
187 typedef struct NetConnInfo NetConnInfo;
190 char *dir; /* connection directory */
191 char *root; /* network root */
192 char *spec; /* binding spec */
193 char *lsys; /* local system */
194 char *lserv; /* local service */
195 char *rsys; /* remote system */
196 char *rserv; /* remote service */
197 char *laddr; /* local address */
198 char *raddr; /* remote address */
202 The information is obtained from the connection directory,
206 is nil, the directory is obtained by performing
211 returns either a completely specified structure, or
212 nil if either the structure can't be allocated or the
213 network directory can't be determined.
216 .IR freenetconninfo .
219 copies the name of the network mount point into
224 It exists to merge two pre-existing conventions for specifying
226 Commands that take a network mount point as a parameter
240 the mount point is set to the default,
244 points to a string starting with a slash,
245 the mount point is that path.
246 Otherwise, the mount point is the string pointed to by
248 appended to the string
250 The last form is obsolete and is should be avoided.
251 It exists only to aid in conversion.
253 Make a call and return an open file descriptor to
254 use for communications:
257 int callkremvax(void)
259 return dial("kremvax", 0, 0, 0);
263 Call the local authentication server:
266 int dialauth(char *service)
268 return dial(netmkaddr("$auth", 0, service), 0, 0, 0);
275 loop forever receiving calls and echoing back
276 to the caller anything sent:
283 char adir[40], ldir[40];
287 acfd = announce("tcp!*!7", adir);
291 /* listen for a call */
292 lcfd = listen(adir, ldir);
295 /* fork a process to echo */
302 /* accept the call and open the data file */
303 dfd = accept(lcfd, ldir);
308 while((n = read(dfd, buf, sizeof(buf))) > 0)
319 .BR /sys/src/libc/9sys ,
320 .B /sys/src/libc/port
330 return \-1 if they fail.
332 returns nonzero if it fails.