]> git.lizzy.rs Git - plan9front.git/blob - sys/man/3/srv
fixing broken path reference
[plan9front.git] / sys / man / 3 / srv
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, create
23 a new file such as
24 .B /srv/myserv
25 and then write a text string (suitable for
26 .IR strtoul ;
27 see
28 .IR atof (2))
29 giving the file descriptor number of an open file.
30 Any process may then open
31 .B /srv/myserv
32 to acquire another reference to the open file that was registered.
33 .PP
34 An entry in
35 .I srv
36 holds a reference to the associated file even if no process has the
37 file open.  Removing the file from
38 .B /srv
39 releases that reference.
40 .PP
41 It is an error to write more than one number into a server file,
42 or to create a file with a name that is already being used.
43 .SH EXAMPLE
44 To drop one end of a pipe into
45 .BR /srv ,
46 that is, to create a named pipe:
47 .IP
48 .EX
49 int fd, p[2];
50 char buf[32];
51
52 pipe(p);
53 fd = create("/srv/namedpipe", OWRITE, 0666);
54 fprint(fd, "%d", p[0]);
55 close(fd);
56 close(p[0]);
57 fprint(p[1], "hello");
58 .EE
59 .PP
60 At this point, any process may open and read
61 .B /srv/namedpipe
62 to receive the
63 .B hello
64 string.  Data written to
65 .B /srv/namedpipe
66 can be received by executing
67 .IP
68 .EX
69 read(p[1], buf, sizeof buf);
70 .EE
71 .PP
72 in the above process.
73 .SH SOURCE
74 .B /sys/src/9/port/devsrv.c