...
The following example shows a function that could be registered in lmxserverconf.c:
Code Block |
---|
|
/* The function parameters should be overwritten by the response back to the client. */ |
...
void LMX_CALLBACK ServerFunc(char *szMessage) |
...
...
char *szTest = "this is a simple response"; |
...
LmxLogprintf("server function called: %s", szMessage); |
...
/* Use the client message in some way ...*/ |
...
...
...
...
...
strcpy(szMessage, szTest); |
...
The client can then invoke the function given above as follows:
Code Block |
---|
|
char szMyMessage[LMX_MAX_LONG_STRING_LENGTH+1]; |
...
char *szString = "This is my simple query"; |
...
...
...
/* Specify a message to send (here we use a zero-terminated string, but any data could be used */ |
...
strcpy(szMyMessage, szString); |
...
LmxStat = LMX_ServerFunction(handle, "f1", szMyMessage); |
...
/* Now the query has been replaced with a response */ |
...
/* Print out the response since we know the server sent us a string */ |
...
printf("%s\n", szMyMessage); |