WSLinkName (C Function)

const char * WSLinkName(WSLINK link)

returns the name string used to create the link.


  • WSLinkName() allocates memory for the link name that must be released. To release the memory, call WSReleaseLinkName() on the value returned by the function. If WSLinkName() returns NULL, do not call WSReleaseLinkName() on the NULL value.
  • Programs should not modify the contents of the string returned by WSLinkName().
  • WSTP links are created using a combination of link mode, link protocol, and other options. The link name provides necessary information for the link mode and link protocol used to create the link.
  • WSLinkName() is declared in the WSTP header file wstp.h.


Basic Examples  (3)

Links opened using LinkLaunch use the complete command line executed as the link name:

The complete link name is stored as the first element of the LinkObject:

Links opened using LinkCreate have a protocol-dependent name with connection information:

The default "SharedMemory" protocol will use the name of the shared memory object:

Declare a const char * variable and get the link name:

#include "wstp.h"

/* A function for reading a link's name */

void f(WSLINK lp)
    const char *name;

    name = WSLinkName(lp);
    if(name == (const char *)0)
    { /* Unable to get the link name */ }

    /* ... */

    WSReleaseLinkName(lp, name);