WSResolveCallbackFunction
This feature is not supported on the Wolfram Cloud.


is a WSTP type that describes a function pointer to a function taking an WSENV object, an WSServiceRef object, a const char * string holding the service name, a const char * string holding the link name, a const char * string holding the link protocol, an int holding the link options, and a void * object as a context object and returning void.

DetailsDetails

  • The function WSResolveLinkService() initiates a resolve operation on the network to convert a WSTP service name to the connection details necessary for establishing a link to the service. WSResolveLinkService() starts the operation and returns immediately. The WSTP library delivers the connection details asynchronously to the application via a function of type WSResolveCallbackFunction.
  • An WSResolveLinkService function has the following form:
  • void function( WSENV e, WSServiceRef r, const char *serviceName, const char *linkName, const char *protocol, int options, void *context);
  • Because WSTP link services primarily involve services available via the network, the protocol option will almost always be "TCPIP".
  • The combination of the link name, protocol, and options argument is sufficient to create a link that will connect to the named service. The link must be created in connect mode using either -linkmode connect or -linkconnect.

ExamplesExamplesopen allclose all

Basic Examples  (1)Basic Examples  (1)

#include <string.h> /* for memset, memcpy, etc... */
#include <stdio.h> /* for snprintf */
#include "wstp.h"

void ResolveCallbackFunction(WSENV e, WSServiceRef r, const char *serviceName, const char *linkName, const char *protocol, int options, void *context);

WSServiceRef startResolvingServiceWithName(WSENV e, const char *name)
{
    WSServiceRef theRef;
    int apiResult = 0;

    apiResult = WSResolveLinkService(e, ResolveCallbackFunction, name,
        NULL /* No context object for this example */, &theRef);
    if(apiResult != 0)
    { /* Handle the error */ }

    return theRef;
}


void ResolveCallbackFunction(WSENV e, WSServiceRef r, const char *serviceName, const char *linkName, const char *protocol, int options, void *context)
{
    WSINK newLink = (WSINK)0;
    int error = 0;
    int argc = 0;
    const char *argv[] = {
        "Dummy value representing program name",
        "-linkname",
        (const char *)0,
        "-linkprotocol",
        (const char *)0,
        "-linkconnect",
        "-linkoptions",
        (const char *)0,
        /* The following NULL pointer terminates the argv array */
        (const char *)0
    };

    char optionsBuffer[50];

    memset((void *)optionsBuffer, 0, sizeof(char) * 50));

    snprintf(optionsBuffer, 50, "%d", options);

    argv[2] = linkName;
    argv[4] = protocol;
    argv[7] = (const char *)optionsBuffer;

    argc = 8;

    newLink = WSOpenArgcArgv(e, argc, argv, &error);
    if(newLink == (WSINK)0 || error != WSEOK)
    { /* Handle the error */ }

    /* ... */

    return;
}