name_open()

Updated: October 26, 2022

Open a name to connect to a server

Synopsis:

#include <sys/iofunc.h>
#include <sys/dispatch.h>

int name_open( const char * name, 
               int flags );

Arguments:

name
The name that you want to open to connect to a server.
flags
Flags that affect the function's behavior; zero or more of the following:
  • NAME_FLAG_ATTACH_GLOBAL — search for the name globally instead of locally.
  • _NAME_FLAG_COF_CLOEXEC (QNX Neutrino 7.0.4 or later) — corresponds to _NTO_COF_CLOEXEC
  • _NAME_FLAG_COF_INSECURE (QNX Neutrino 7.0.4 or later) — corresponds to _NTO_COF_INSECURE
  • _NAME_FLAG_COF_NOEVENT (QNX Neutrino 7.0.4 or later) — corresponds to _NTO_COF_NOEVENT
  • _NAME_FLAG_COF_REG_EVENTS (QNX Neutrino 7.0.4 or later) — corresponds to _NTO_COF_REG_EVENTS

For more information about the _NTO_COF_* flags, see ConnectAttach().

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The name_open() function opens name to connect to the server that registered that name. No ordering is guaranteed when accessing resources on other nodes. There's also no guarantee that the client will end up talking to the server it thinks it's connecting to; another server process could run before the server the client is expecting to talk to and use the name in name. If this is a concern, your server should call resmgr_attach() instead of name_attach() and possibly configure a security policy.

You can make the connection more secure by setting the _NAME_FLAG_COF_INSECURE and _NAME_FLAG_COF_NOEVENT flags. For more information, see the descriptions of the corresponding ConnectAttach() flags.

Note: The server application must be able handle an _IO_CONNECT message with a subtype of _IO_CONNECT_OPEN. If the global name service, gns, is running on your system, this message is sent to the server when a client calls name_open(). For an example, see the documentation for name_attach().

Returns:

A nonnegative integer representing a side-channel connection ID or coid (see ConnectAttach()), or -1 if an error occurred (errno is set).

Errors:

EACCES
Search permission is denied on a component of the name.
EBADFSYS
While attempting to open the named file, either the file itself or a component of the path prefix was found to be corrupted. A system failure—from which no automatic recovery is possible—occurred while the file was being written to, or while the directory was being updated. You'll need to invoke appropriate systems-administration procedures to correct this situation before proceeding.
EBUSY
The connection specified by name has already been opened, and additional connections aren't permitted.
EINTR
The name_open() operation was interrupted by a signal.
EISDIR
The named path is a directory.
ELOOP
Too many levels of symbolic links or prefixes.
EMFILE
All file descriptors available to the process are currently open.
ENAMETOOLONG
The length of the name string exceeds PATH_MAX, or a pathname component is longer than NAME_MAX.
ENFILE
Too many files are currently open in the system.
ENOENT
The connection specified by name doesn't exist.
ENOTDIR
A component of the name prefix isn't a directory.

Examples:

See name_attach().

Classification:

QNX Neutrino

Safety:  
Cancellation point Yes
Interrupt handler No
Signal handler Yes
Thread Yes