setsockprefix()

Updated: April 19, 2023

Set or get the prefix for the networking stack path for the current thread

Synopsis:

#include <sys/socket.h>

const char * setsockprefix( const char * prefix_val );

Arguments:

prefix_val
The prefix to prepend to the networking stack path (/dev/socket). Set to NULL to return the current prefix value used for the thread.

Library:

libsocket

Use the -l socket option to qcc to link against this library.

Description:

The setsockprefix() function allows you to set a path prefix for the networking stack (/dev/socket by default), for a specific thread.

For multithreaded applications, different threads can communicate with different io-sock instances, therefore making it easy for an application (e.g., gateway or proxy) to bridge two or more io-sock instances.

This feature overrides the SOCK environment variable for the affected thread. SOCK sets a default prefix for all threads in a program, while setsockprefix() configures a prefix for individual threads. Use clearsockprefix() to revert to using the prefix specified by SOCK. If you specify an empty prefix, (i.e., "" ), the value of SOCK is ignored and the thread connects to the io-sock instance at /dev/socket.

Returns:

If successful, setsockprefix() either returns the specified prefix, or, if prefix_val is NULL, the current prefix value set for the thread.

If it fails to set the prefix, it returns NULL.

Classification:

QNX Neutrino

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