WSNewLinkServer (C Function)

WSLinkServer WSNewLinkServer(WSENV e, void *c, int *err)

starts a new TCPIP link server on a port and interface picked by the WSTP library, using context object c, and returning error conditions in err.

Details

  • 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.
  • WSNewLinkServer() creates a TCPIP link protocol WSTP endpoint on the network that allows many clients to connect.
  • WSNewLinkServer() creates a WSTP endpoint that can only be connected to by a WSTP interface 4 compatible program.
  • WSNewLinkServer() allows the WSTP library pick the port and interface to use for the link server.
  • The link server object will queue incoming connections that can be processed synchronously with the function WSWaitForNewLinkFromLinkServer(), or asynchronously by registering a callback function with WSRegisterCallbackFunctionWithLinkServer().
  • The context object c may be a pointer to any object needed by the program to manager link connections created by the link server. The user can retrieve the context object using the function WSContextFromLinkServer().
  • WSNewLinkServer() sets err to 0 if the function succeeds and a nonzero value if the function fails.
  • The nonzero values that indicate an error condition correspond to the WSE error codes in wstp.h and as returned by WSError().
  • Use WSShutdownLinkServer() to close down the link server mechanism.

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);
}