OpenersNotesSection(Spacer1)Details

Sometimes it is useful to identify sides of a WSTP connection prior to setting up packet-based communication. Using (NonWLLink[WSSetEnvIDString(), paclet:ref/c/WSSetEnvIDString]) the developer can give an identification string for a program that will be exchanged every time a link is established with another program. (NonWLLink[WSGetLinkedEnvIDString(), paclet:ref/c/WSGetLinkedEnvIDString]) retrieves the other side of the link's name.

WSReleaseEnvIDString() is declared in the WSTP header file (RefLink[wstp.h, paclet:ref/file/wstp.h]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

#include <string.h>
#include "wstp.h"

/* read the other side of the link's id string and check that it is "My Remote Program" */

int f(WSLINK lp)
{
	int isCorrectProg;
	const char *envid;

	if(! WSGetLinkedEnvIDString(lp, &envid))
		{ /* unable to get remote side id from lp */ }

	isCorrectProg = strcmp(envid, "My Remote Program") == 0;

	WSReleaseEnvIDString(lp, envid, length);

	return isCorrectProg;
}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(NonWLLink[WSGetLinkedEnvIDString(), paclet:ref/c/WSGetLinkedEnvIDString])  ▪  (NonWLLink[WSSetEnvIDString(), paclet:ref/c/WSSetEnvIDString])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[WSTP C API Developer Guide (Mac OS X), paclet:tutorial/WSTPDeveloperGuide-MacintoshOverview])}, {▪(RefLinkPlain[WSTP C API Developer Guide (Unix and Linux), paclet:tutorial/WSTPDeveloperGuide-UnixOverview])}, {▪(RefLinkPlain[WSTP C API Developer Guide (Windows), paclet:tutorial/WSTPDeveloperGuide-WindowsOverview])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Alphabetical Listing of WSTP C Functions, paclet:guide/AlphabeticalListingOfWSTPCFunctions])}})}})