({{, (RefLink[LinkWrite, paclet:ref/LinkWrite])[link,expr]
writes expr to the specified WSTP connection. }})

OpenersNotesSection(Spacer1)Details

link must be an active (RefLink[LinkObject, paclet:ref/LinkObject]), as returned by functions like (RefLink[LinkLaunch, paclet:ref/LinkLaunch]) or (RefLink[Links, paclet:ref/Links]).

You can use (RefLink[LinkWrite, paclet:ref/LinkWrite])[link,(RefLink[Unevaluated, paclet:ref/Unevaluated])[expr]] to write expr to the link without evaluating it.

The head of expr will often be a packet that specifies how expr should be processed by the program which receives it.

When (RefLink[LinkWrite, paclet:ref/LinkWrite]) is used to send data to a Wolfram Language kernel, (RefLink[EnterTextPacket, paclet:ref/EnterTextPacket])["string"] enters the text of an input line, and (RefLink[EvaluatePacket, paclet:ref/EvaluatePacket])[expr] sends an expression for evaluation.

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Launch a subsidiary Wolfram Language kernel process:

link=LinkLaunch[First[$CommandLine] <> " -wstp"]

Read the first packet:

LinkRead[link]

Write the expression 2+2 to the link without evaluating it:

LinkWrite[link,Unevaluated[2+2]]

Read the result:

LinkRead[link]

Close the link:

LinkClose[link]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[LinkRead, paclet:ref/LinkRead])  ▪  (RefLink[Write, paclet:ref/Write])  ▪  (RefLink[FrontEndExecute, paclet:ref/FrontEndExecute])  ▪  (RefLink[LinkReadyQ, paclet:ref/LinkReadyQ])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Using WSTP to Communicate between Wolfram System Sessions, paclet:tutorial/UsingWSTPToCommunicateBetweenWolframSystemSessions])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[WSTP Wolfram Language Functions, paclet:guide/WSTPWolframLanguageFunctions])}, {▪(RefLinkPlain[WSTP API, paclet:guide/WSTPAPI])}, {▪(RefLinkPlain[Calling External Programs, paclet:guide/CallingExternalPrograms])}, {▪(RefLinkPlain[External Operations, paclet:guide/ExternalOperations])}, {▪(RefLinkPlain[External Language Interfaces, paclet:guide/ExternalLanguageInterfaces])}, {▪(RefLinkPlain[WSTP Expression Packet Handling, paclet:guide/WSTPExpressionPacketHandling])}})}})