[Previous]
[Contents]
[Next]

qnx_net_alive()

determine the status of all nodes on the network

Synopsis:

#include <sys/name.h>
int qnx_net_alive( char *buf, int buflen );

Description:

This function determines the status of all nodes on the network. It does this by sending a message to the first nameloc name locator it encounters. The nameloc command polls the network, looking for names, and thus knows the status of all nodes.

The arguments are as follows:

buf
a pointer to an array of bytes, into which you can index by node number. For example, buf[5] is the status of node 5 as returned by nameloc. The first byte, buf[0], isn't used.
buflen
the total length of buf. The qnx_net_alive() function won't write more than buflen bytes to buf. You should make sure that buflen is larger than the number of nodes on the network.

If no nameloc is found, all nids are reported as up.

On a network with more than one media (for example, arcnet and ethernet), nameloc reports as up only the nodes it can talk to. Therefore, run nameloc on a node with lots of network cards, such as a server.

Confusion can result when multiple namelocs are running, some on nodes that can or can't see other nodes.

Remember that qnx_net_alive() returns the best guess of the nodes' status, as determined by nameloc. This information cannot be guaranteed to be correct, given the hardware-independent way that nameloc collects this information.

There are always timing windows: for example, a node is just turned on, but reported as down by qnx_net_alive(), or a node is just turned off, but reported as up.

Returns:

The valid length of the buffer as returned by nameloc.

Examples:

#include <stdio.h>
#include <stdlib.h>
#include <sys/name.h>


main(argc, argv)
int argc;
char *argv[];
{
    int I;
    int num_nids;
    static char buffer[500];

    if ((num_nids=qnx_net_alive(buffer,500)) == -1) {
        printf("qnx_net_alive() failed\n");
        exit(1);
    }

    /* zero-based */
    for(I=1; I < num_nids+1; I++){
        printf("%3d  %s\n", I, buffer[I] ? "up" : "down");
    }

}

Classification:

QNX

Safety:
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

nameloc utility


[Previous]
[Contents]
[Next]