1GETFDS(3PVM)                    PVM Version 3.4                   GETFDS(3PVM)
2
3
4

NAME

6       pvm_getfds - Get file descriptors in use by PVM.
7
8

SYNOPSIS

10       C    int nfds = pvm_getfds( int **fds )
11
12       Fortran   Not Available
13
14

PARAMETERS

16       fds     Returns integer array of file descriptors.
17
18

DESCRIPTION

20       A  PVM  task uses sockets to communicate between libpvm and other tasks
21       or the pvmd.  It is sometimes useful to know the file  descriptor  num‐
22       bers  of  the  sockets in order to wait from input from either PVM mes‐
23       sages or an external source.  For example, the  PVM  console  waits  on
24       both  keyboard  input and notify messages.  Input can be multiplexed by
25       polling all sources, but this wastes cpu cycles.  Instead, the select()
26       system  call can be used to wait until one or more sources of input are
27       ready.
28
29       If it completes successfully, pvm_getfds returns the number of  sockets
30       in  use,  and  the  file  descriptor numbers in an array (allocated and
31       freed by libpvm).  At least one socket  always  exists  (from  task  to
32       pvmd),  and  its  descriptor  is  always fds[0].  The number of sockets
33       varies as direct routes are established to other tasks.
34
35       It can be difficult to track the set  of  file  descriptors  if  direct
36       routing  is  enabled, because routes are created as messages are either
37       sent or received.  The simplest approach is to disable direct routing.
38
39       When select returns with a PVM file descriptor ready, a  complete  mes‐
40       sage  may  be  ready  to be received, or instead only a fragment may be
41       waiting.  pvm_nrecv or pvm_probe should be used test without blocking.
42
43

RESTRICTIONS

45       pvm_getfds is only available when running PVM on a Unix or similar sys‐
46       tem.
47
48

EXAMPLES

50       The  following  program  fragment  waits until either keyboard input is
51       available, or a PVM message has arrived.
52
53            int *d;
54            fd_set r;
55
56            pvm_setopt(PvmRoute, PvmDontRoute);
57            pvm_getfds(&d);
58
59            FD_ZERO(&r);
60            FD_SET(0, &r);
61            FD_SET(d[0], &r);
62            while (1) {
63                 if (select(d[0] + 1, &r, (fd_set*)0, (fd_set*)0,
64                            (struct timeval*)0) > 0) {
65                      if (FD_ISSET(0, &r))
66                           ...    /* read keyboard input */
67                      if (FD_ISSET(d[0], &r) && pvm_nrecv(-1, -1) > 0)
68                           ...    /* got a PVM message */
69                 }
70            }
71
72

ERRORS

74       The following error condition can be returned by pvm_getfds:
75
76       PvmSysErr
77              pvmd not responding.
78

SEE ALSO

80       pvm_notify(3PVM), pvm_trecv(3PVM)
81
82
83
84                                 22 Nov, 1994                     GETFDS(3PVM)
Impressum