WSBrowseCallbackFunction
This feature is not supported on the Wolfram Cloud.

WSBrowseCallbackFunction
is a WSTP type that describes a function pointer to a function taking an WSENV object, an WSServiceRef object, an int object, a const char * object, and a void * object as arguments and returning void.

DetailsDetails

  • The function WSBrowseForLinkServices() initiates a browse operation on the network to find available WSTP link services. WSBrowseForLinkServices() only starts the browse operation and returns immediately. The WSTP library will asynchronously call back to the application via a function typed as an WSBrowseCallbackFunction in order to update the program on network browse events.
  • An WSBrowseCallbackFunction function has the following form:
  • void function(MLENV e, WSServiceRef r, int flags, const char *name, void *context);
  • The int argument contains flags representing the type of event that has occurred on the network.
  • The flag argument can have the following values:
  • WSSDADDSERVICEthe const char * argument contains a pointer to the name of the new service now available on the network
    WSSDREMOVESERVICEthe const char * argument contains a pointer to the name of a service that is no longer available on the network
    WSSDBROWSEERRORan error has occurred in the browse operation; the program should use WSStopBrowsingForLinkServices() to terminate the browse operation; in addition all cached service names should be removed; to receive further updates from the library regarding browse events the program must call WSBrowseForLinkServices() again and initiate a new browse operation

ExamplesExamplesopen allclose all

Basic Examples  (1)Basic Examples  (1)

#include "wstp.h"

void BrowseCallbackFunction(MLENV env, WSServiceRef ref, int flags, const char *serviceName, void *context);

WSServiceRef startBrowseOperation(MLENV e)
{
    int apiResult;
    WSServiceRef theRef;

    apiResult = WSBrowseForLinkServices(e, BrowseCallbackFunction, NULL /* Use the default browse domain */, NULL /* no specific context object for this example */, &theRef);
    if(apiResult != 0)
    { /* Handle the error. */ }

    return theRef;
}


void BrowseCallbackFunction(MLENV env, WSServiceRef ref, int flags, const char *serviceName, void *context)
{
    if(flags & MLSDADDSERVICE)
    { /* Register the service named in serviceName */ }
    else if(flags & MLSDREMOVESERVICE)
    { /* Remove the service named in serviceName from the registry */ }
    else if(flags & MLSDBROWSEERROR)
    { /* Stop the browse operation and clear the service name cache */ }
}