OpenersNotesSection(Spacer1)Details

Calling WSClose() does not necessarily terminate a program at the other end of the link.

Any data buffered in the link is sent when WSClose() is called.

Programs should close all links they have opened before terminating.

WSClose() 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"

int main(int argc, char **argv)
{
	WSENV ep;
	WSLINK lp;
	int error;

	ep = WSInitialize((WSParametersPointer)0);
	if(ep == (WSENV)0)
		{ /* environment initialization failed */ }

	lp = WSOpenArgv(ep, argv, argv + argc, &error);
	if(lp == (WSLINK)0 || error != WSEOK)
		{ /* link creation failed */ }

	...

	WSClose(lp);
	WSDeinitialize(ep);

	return 0;
}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(NonWLLink[WSInitialize(), paclet:ref/c/WSInitialize])  ▪  (NonWLLink[WSDeinitialize(), paclet:ref/c/WSDeinitialize])  ▪  (NonWLLink[WSOpenArgcArgv(), paclet:ref/c/WSOpenArgcArgv])  ▪  (NonWLLink[WSOpenString(), paclet:ref/c/WSOpenString])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Running the Wolfram System from within an External Program, paclet:tutorial/RunningTheWolframSystemFromWithinAnExternalProgram])}, {▪(RefLinkPlain[Manipulating Expressions in External Programs, paclet:tutorial/ManipulatingExpressionsInExternalPrograms])}, {▪(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[WSTP C Language Functions, paclet:guide/WSTPCLanguageFunctions])}, {▪(RefLinkPlain[WSTP Connection Management, paclet:guide/WSTPConnectionManagement])}})}})