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, and returns an open
145 used in announce may be a local address or an asterisk,
146 to indicate all local addresses, e.g.
150 routine takes as its first argument the
154 When a call is received,
158 file for the line the call was received on.
161 to the path name of the new line directory.
163 accepts a call received by
167 refuses the call because of
170 returns a file descriptor for the data file opened
174 makes an address suitable for dialing or announcing.
175 It takes an address along with a default network and service to use
176 if they are not specified in the address.
177 It returns a pointer to static data holding the actual address to use.
180 returns a structure containing information about a
181 network connection. The structure is:
183 typedef struct NetConnInfo NetConnInfo;
186 char *dir; /* connection directory */
187 char *root; /* network root */
188 char *spec; /* binding spec */
189 char *lsys; /* local system */
190 char *lserv; /* local service */
191 char *rsys; /* remote system */
192 char *rserv; /* remote service */
193 char *laddr; /* local address */
194 char *raddr; /* remote address */
198 The information is obtained from the connection directory,
202 is nil, the directory is obtained by performing
207 returns either a completely specified structure, or
208 nil if either the structure can't be allocated or the
209 network directory can't be determined.
212 .IR freenetconninfo .
215 copies the name of the network mount point into
220 It exists to merge two pre-existing conventions for specifying
222 Commands that take a network mount point as a parameter
236 the mount point is set to the default,
240 points to a string starting with a slash,
241 the mount point is that path.
242 Otherwise, the mount point is the string pointed to by
244 appended to the string
246 The last form is obsolete and it should be avoided.
247 It exists only to aid in conversion.
249 Make a call and return an open file descriptor to
250 use for communications:
253 int callkremvax(void)
255 return dial("kremvax", nil, nil, nil);
259 Call the local authentication server:
262 int dialauth(char *service)
264 return dial(netmkaddr("$auth", nil, service), nil, nil, nil);
271 loop forever receiving calls and echoing back
272 to the caller anything sent:
279 char adir[40], ldir[40];
283 acfd = announce("tcp!*!7", adir);
287 /* listen for a call */
288 lcfd = listen(adir, ldir);
291 /* fork a process to echo */
298 /* accept the call and open the data file */
299 dfd = accept(lcfd, ldir);
304 while((n = read(dfd, buf, sizeof(buf))) > 0)
315 .BR /sys/src/libc/9sys ,
316 .B /sys/src/libc/port
326 return \-1 if they fail.
328 returns nonzero if it fails.