[Previous]
[Contents]
[Next]

qnx_vc_name_attach()

establish a virtual circuit to a process with the given name

Synopsis:

#include <sys/vc.h>
pid_t qnx_vc_name_attach( nid_t nid,
                          unsigned length,
                          char *name );

Description:

The qnx_vc_name_attach() function attempts to establish a network link, called a virtual circuit, between your process, on your local node, and a remote process that has registered name on the remote node nid. An initial buffer of size length bytes is allocated on both the local and remote node.

Once a virtual circuit is attached, the two programs may communicate using the kernel functions (for example, Send(), Receive(), and Reply()) as if they were on the same node.

See the qnx_vc_attach() function for more detail about virtual circuits. The qnx_vc_name_attach() function is simply a version of qnx_vc_attach() that allows you to attach a virtual circuit to a process on another node without knowing its process ID, as long as you know a name it has registered. Virtual circuits and their message buffers are always allocated (that is, not shared) when you use the qnx_vc_name_attach() function.

If you specify zero or your own node number for nid, a search for a process that has registered name is conducted locally. If a match is found, the process ID of the local process is returned, and no virtual circuit is created.

Returns:

The virtual process ID (vid) on your local node upon success. On error, -1 is returned and errno is set.

Errors:

See qnx_vc_attach().

Examples:

#include <stdio.h>
#include <errno.h>
#include <sys/vc.h>
#include <sys/kernel.h>

nid_t    nid;
pid_t    vid;
char    msg[1000];

void main()
  {
    nid = 2;

    /*
     *    set up a vc to some manager on node 2 that has
     *    registered the name "Resource", with an initial
     *    vid buffer size of 1000 bytes.
     */
    if( ( vid = qnx_vc_name_attach( nid, 1000,
     "Resource" ) ) == -1 ) {
      printf( "qnx_vc_name_attach() failed: " );
      printf( "errno = %d\n", errno );
    }

    /*
     *    send the manager 10 bytes, limit
     *    reply to 1000 bytes
     */
    if( Send( vid, msg, msg, 10, 1000 ) == -1 ) {
      printf( "Send() on vid %d failed: ", vid );
      printf( "errno = %d\n", errno );
    }
    qnx_vc_detach( vid );
  }

Classification:

QNX

Safety:
Interrupt handler No
Signal handler Yes, but modifies errno
Thread Yes

See also:

Creceive(), Creceivemx(), errno, qnx_name_attach(), qnx_vc_attach(), qnx_vc_detach(), Receive(), Receivemx(), Reply(), Replymx(), Readmsg(), Readmsgmx(), Send(), Sendfd(), Sendfdmx(), Sendmx(), Trigger(), Writemsg(), Writemsgmx()


[Previous]
[Contents]
[Next]