Updated: April 19, 2023 |
Set or get the prefix for the networking stack path for the current thread
#include <sys/socket.h> const char * setsockprefix( const char * prefix_val );
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-pkt instances, therefore making it easy for an application (e.g., gateway or proxy) to bridge two or more io-pkt 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-pkt instance at /dev/socket.
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.
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | No |
Thread | Yes |