GETFDSSection: PVM Version 3.4 (3PVM)Updated: 22 Nov, 1994 |
GETFDSSection: PVM Version 3.4 (3PVM)Updated: 22 Nov, 1994 |
C int nfds = pvm_getfds( int **fds )
Fortran Not Available
If it completes successfully, pvm_getfds returns the number of sockets in use, and the file descriptor numbers in an array (allocated and freed by libpvm). At least one socket always exists (from task to pvmd), and its descriptor is always fds[0]. The number of sockets varies as direct routes are established to other tasks.
It can be difficult to track the set of file descriptors if direct routing is enabled, because routes are created as messages are either sent or received. The simplest approach is to disable direct routing.
When select returns with a PVM file descriptor ready, a complete message may be ready to be received, or instead only a fragment may be waiting. pvm_nrecv or pvm_probe should be used test without blocking.
int *d;
fd_set r;
pvm_setopt(PvmRoute, PvmDontRoute);
pvm_getfds(&d);
FD_ZERO(&r);
FD_SET(0, &r);
FD_SET(d[0], &r);
while (1) {
if (select(d[0] + 1, &r, (fd_set*)0, (fd_set*)0,
(struct timeval*)0) > 0) {
if (FD_ISSET(0, &r))
... /* read keyboard input */
if (FD_ISSET(d[0], &r) && pvm_nrecv(-1, -1) > 0)
... /* got a PVM message */
}
}