WSLinkServer (C Function)
WSLinkServer
is a WSTP type representing a WSTP link server.
Details
- The WSTP link server object is a handle to the object that manages the TCPIP link server network interface.
- In the normal course of using the Wolfram Symbolic Transfer Protocol, connections made between processes function on a one-to-one standard, meaning that when program A connects to program B, only A and B can use the communication endpoints established between A and B. This one-to-one model differs from a traditional client/server communication model where a server advertises a connection in a one-to-many mode where the server has one connection and many clients connect to that one connection. The WSTP link server functionality allows the user to create a program that offers a one-to-many connection using the Wolfram Symbolic Transfer Protocol.
- The program interacts with the link server object to retrieve new WSLINK objects created from incoming WSTP connections to the link server endpoint.
- The link server object will queue up incoming connections until one of two things happens; either the program calls WSWaitForNewLinkFromLinkServer() or the program registers an asynchronous callback function with the link server object via the WSRegisterCallbackFunctionWithLinkServer(). If the former occurs, the link server will return one new WSLINK object to the program from its queue of connections per call to WSWaitForNewLinkFromLinkServer(). In the latter case, the link server object will asynchronously call the callback function with one WSLINK object passed as an argument to the callback function per call until the connection queue is empty.
- WSLinkServer is declared in the WSTP header file wstp.h.
Examples
Basic Examples (1)
#include "wstp.h"
void operateLinkServer(WSENV env)
{
int error;
WSLinkServer linkServer;
WSLINK theLink;
linkServer = WSNewLinkServer(env, NULL /* No context object for
this example */, &error);
if(error != WSEOK)
{ /* Handle error */ }
theLink = WSWaitForNewLinkFromLinkserver(linkServer, &error);
if(theLink == (WSLINK)0 || error != WSEOK)
{ /* Handle error */ }
...
WSCLose(theLink);
WSShutdownLinkServer(linkServer);
}