is a WSTP type that describes a function pointer to a function taking a WSLinkServer object, and a WSLINK object as arguments and returning void.


  • The function WSRegisterCallbackFunctionWithLinkServer() allows a program to 'install' a callback function with a link server object. The link server object will call the callback function when a program has connected to the link server endpoint. The WSLINK object can be used to communicate with the new program.
  • A WSNewLinkCallbackFunction has the following form:
  • void function(WSLinkServer s, WSLINK l);
  • The link server will handle incoming connections asynchronously if the program registers a callback function. The callback function must take any necessary steps to guard shared data structures against asynchronous access.
  • To use the new WSLINK object, the program must call WSActivate() on the link object prior to other link operations.

ExamplesExamplesopen allclose all

Basic Examples  (1)Basic Examples  (1)

#include "wstp.h"

void NewLinkCallbackFunction(WSLinkServer server, WSLINK link);

WSLinkServer startLinkServer(WSENV env)
    WSLinkServer theServer;
    int error;

    theServer = WSNewLinkServer(env, NULL /* No context object
        for this example */, &error);
    if(error != WSEOK)
    { /* Handle error */ }


    return theServer;

void NewLinkCallbackFunction(WSLinkServer server, WSLINK link)
        WSPutString(link, "Hello Client Program");


Translate this page: