OpenersNotesSection(Spacer1)Details

WSTP messages provide out-of-band message sending and receiving that is not tied to the normal transfer of data.

WSPutMessageWithArg() returns 0 in the event of an error, and a nonzero value if the function succeeds.

Use (NonWLLink[WSError(), paclet:ref/c/WSError]) to retrieve the error code if WSPutMessageWithArg() fails.

WSPutMessageWithArg() 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 "wstp.h"


/* define some custom messages and arguments */

#define AppMenuMessage WSFirstUserMessage + 1

#define AppMenuOption1 1
#define AppMenuOption2 2

/* send an AppMenuMessage to a link */

void f(WSLINK lp)
{
	if(! WSPutMessageWithArg(lp, AppMenuMessage, AppMenuOption2))
		{ /* unable to send the message to lp */ }
}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(NonWLLink[WSPutMessage(), paclet:ref/c/WSPutMessage])  ▪  (NonWLLink[WSMessageReady(), paclet:ref/c/WSMessageReady])  ▪  (NonWLLink[WSGetMessage(), paclet:ref/c/WSGetMessage])  ▪  (NonWLLink[WSSetMessageHandler(), paclet:ref/c/WSSetMessageHandler])  ▪  (NonWLLink[WSGetMessageHandler(), paclet:ref/c/WSGetMessageHandler])}})}})

({{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])}, {▪(RefLinkPlain[Low-Level WSTP Operations, paclet:guide/LowLevelWSTPOperations])}})}})