Annotation of lucent/sys/man/3/srv, revision 1.1.1.1

1.1       root        1: .TH SRV 3 
                      2: .SH NAME
                      3: srv \- server registry
                      4: .SH SYNOPSIS
                      5: .nf
                      6: .B bind #s /srv
                      7: 
                      8: .BI #s/ service1
                      9: .BI #s/ service2
                     10:  ...
                     11: .fi
                     12: .SH DESCRIPTION
                     13: The
                     14: .I srv
                     15: device provides a one-level directory holding
                     16: already-open channels to services.
                     17: In effect,
                     18: .I srv
                     19: is a bulletin board on which processes may post open file descriptors
                     20: to make them available to other processes.
                     21: .PP
                     22: To install a channel,
                     23: .B create
                     24: a new file such as
                     25: .B /srv/myserv
                     26: and then write a text string (suitable for
                     27: .IR strtoul ;
                     28: see
                     29: .IR atof (2))
                     30: giving the file descriptor number of an open file.
                     31: Any process may then open
                     32: .B /srv/myserv
                     33: to acquire another reference to the open file that was registered.
                     34: .PP
                     35: An entry in
                     36: .I srv
                     37: holds a reference to the associated file even if no process has the
                     38: file open.  Removing the file from
                     39: .B /srv
                     40: releases that reference.
                     41: .PP
                     42: It is an error to write more than one number into a server file,
                     43: or to create a file with a name that is already being used.
                     44: .SH EXAMPLE
                     45: To drop one end of a pipe into
                     46: .BR /srv ,
                     47: that is, to create a named pipe:
                     48: .IP
                     49: .EX
                     50: int fd, p[2];
                     51: char buf[32];
                     52: 
                     53: pipe(p);
                     54: fd = create("/srv/namedpipe", 1, 0666);
                     55: sprint(buf, "%d", p[0]);
                     56: write(fd, buf, strlen(buf));
                     57: close(fd);
                     58: close(p[0]);
                     59: write(p[1], "hello", 5);
                     60: .EE
                     61: .PP
                     62: At this point, any process may open and read
                     63: .B /srv/namedpipe
                     64: to receive the
                     65: .B hello
                     66: string.  Data written to
                     67: .B /srv/namedpipe
                     68: will be received by executing
                     69: .IP
                     70: .EX
                     71: read(p[1], buf, sizeof buf);
                     72: .EE
                     73: .PP
                     74: in the above process.
                     75: .SH SOURCE
                     76: .B /sys/src/9/port/devsrv.c

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.