dial, hangup, announce, listen, accept, reject, netmkaddr, setnetmtpt, getnetconninfo, freenetconninfo – make and break network connections
int dial(char *addr, char *local, char *dir, int *cfdp)
int hangup(int ctl)
int announce(char *addr, char *dir)
int listen(char *dir, char *newdir)
int accept(int ctl, char *dir)
int reject(int ctl, char *dir, char *cause)
char* netmkaddr(char *addr, char *defnet, char *defservice)
void setnetmtpt(char *to, int tolen, char *from)
NetConnInfo* getnetconninfo(char *conndir, int fd)
For these routines,
is a network address of the form
is any directory listed in
or the special token,
is a free variable that stands for any network in common
between the source and the host
can be a host name, a domain name, a network address,
or a meta-name of the form
is replaced by
from the value-attribute pair
most closely associated with the source host in the
network data base (see
If a connection attempt is successful and
the path name of a
that has files for accessing the connection
is copied into
The path name is guaranteed to be less than 40
One line directory exists for each possible connection.
file in the line directory should be used to communicate with the destination.
file in the line directory can be used to send commands to the line.
for messages that can be written to the
The last close of the
file will close the connection.
makes a call to destination
on a multiplexed network.
If the network in
will try all addresses on networks in common between source
and destination until a call succeeds.
It returns a file descriptor open for reading and writing the
file in the line directory.
file in the line directory contains the address called.
If the network allows the local address to be set,
as is the case with UDP and TCP port numbers, and
is non-zero, the local address will be set to
is set to a file descriptor open for reading and
writing the control file.
is a means of forcing a connection to hang up without
unhandled troff command .P
are the complements of
establishes a network
name to which calls can be made.
returns an open
used in announce may be a local address or an asterisk,
to indicate all local addresses, e.g.
routine takes as its first argument the
of a previous
When a call is received,
returns an open
file for the line the call was received on.
to the path name of the new line directory.
accepts a call received by
refuses the call because of
returns a file descriptor for the data file opened
makes an address suitable for dialing or announcing.
It takes an address along with a default network and service to use
if they are not specified in the address.
It returns a pointer to static data holding the actual address to use.
returns a structure containing information about a
network connection. The structure is:
typedef struct NetConnInfo NetConnInfo;
char *dir; /* connection directory */
char *root; /* network root */
char *spec; /* binding spec */
char *lsys; /* local system */
char *lserv; /* local service */
char *rsys; /* remote system */
char *rserv; /* remote service */
char *laddr; /* local address */
char *raddr; /* remote address */
The information is obtained from the connection directory,
is nil, the directory is obtained by performing
returns either a completely specified structure, or
nil if either the structure can’t be allocated or the
network directory can’t be determined.
is freed using
copies the name of the network mount point into
whose length is
It exists to merge two pre-existing conventions for specifying
the mount point.
Commands that take a network mount point as a parameter
should now call
the mount point is set to the default,
points to a string starting with a slash,
the mount point is that path.
Otherwise, the mount point is the string pointed to by
appended to the string
The last form is obsolete and is should be avoided.
It exists only to aid in conversion.
Make a call and return an open file descriptor to
use for communications:
return dial("kremvax", 0, 0, 0);
Call the local authentication server:
int dialauth(char *service)
return dial(netmkaddr("$auth", 0, service), 0, 0, 0);
on TCP/IP and
loop forever receiving calls and echoing back
to the caller anything sent:
int dfd, acfd, lcfd;
char adir, ldir;
acfd = announce("tcp!*!7", adir);
if(acfd < 0)
/* listen for a call */
lcfd = listen(adir, ldir);
if(lcfd < 0)
/* fork a process to echo */
/* accept the call and open the data file */
dfd = accept(lcfd, ldir);
if(dfd < 0)
/* echo until EOF */
while((n = read(dfd, buf, sizeof(buf))) > 0)
write(dfd, buf, n);
return –1 if they fail.
returns nonzero if it fails.