Searching for Parallels ServersThis topic applies to Parallels Server only. If you have multiple Parallels Servers running on your network and don't know their exact locations and/or connection parameters, you can search for them using the The To use the Note: The The following sample functions demonstrate how to search local network for Parallels Servers. The first sample function calls the PRL_RESULT SearchServersSynch() { // Variables for handles. PRL_HANDLE hJob = PRL_INVALID_HANDLE; // job handle PRL_HANDLE hJobResult = PRL_INVALID_HANDLE; // job result PRL_HANDLE hHostConfig = PRL_INVALID_HANDLE; // PHT_SERVER_CONFIG
// Variables for return codes. PRL_RESULT ret = PRL_ERR_UNINITIALIZED; PRL_RESULT nJobReturnCode = PRL_ERR_UNINITIALIZED;
// Search for Parallels servers. hJob = PrlSrv_LookupParallelsServers( 1000, // timeout NULL, // callback function (not used) NULL // user object pointer (not used) );
// Wait for the job to complete. ret = PrlJob_Wait(hJob, 10000); if (PRL_FAILED(ret)) { // Handle the error... PrlHandle_Free(hJob); fprintf(stderr, "Error: %s. \n", prl_result_to_string(ret)); return -1; }
// Analyze the result of PrlSrv_LookupParallelsServers. ret = PrlJob_GetRetCode(hJob, &nJobReturnCode); if (PRL_FAILED(ret)) { // Handle the error... PrlHandle_Free(hJob); return -1; } // Get the job return code. if (PRL_FAILED(nJobReturnCode)) { // Handle the error... PrlHandle_Free(hJob); return -1; }
// Get job result. ret = PrlJob_GetResult(hJob, &hJobResult); PrlHandle_Free(hJob); if (PRL_FAILED(ret)) { // Handle the error... return -1; }
// Get the number of objects returned. PRL_UINT32 nCount = 0; PrlResult_GetParamsCount(hJobResult, &nCount);
// Iterate and a obtain handle to each object. for (PRL_UINT32 i = 0; i < nCount ; ++i) { PRL_HANDLE hParam = PRL_INVALID_HANDLE; PrlResult_GetParamByIndex(hJobResult, i, &hParam);
PRL_CHAR sBuf[1024]; PRL_UINT32 nBufSize = sizeof(sBuf);
// Get the host name. ret = PrlSrvInfo_GetHostName(hParam, sBuf, &nBufSize);
if (PRL_SUCCEEDED(ret)) { printf("Found Parallels Server: %s\n", sBuf); } else { fprintf(stderr, "Error: %s \n", prl_result_to_string(ret)); }
PrlHandle_Free(hParam); } } In the following example, the static PRL_RESULT ourCallback(PRL_HANDLE hEvent, PRL_VOID_PTR pUserData) { printf("%s: ", pUserData);
// Get the host name. PRL_UINT32 nBufSize = 1024; PRL_CHAR sBuf[nBufSize]; PrlSrvInfo_GetHostName(hEvent, sBuf, &nBufSize);
// Get the other server properties and process them here, if needed...
// The handle must be freed. PrlHandle_Free(hEvent); return rc; } The hJob = PrlSrv_LookupParallelsServers( 1000, &ourCallback, (PRL_VOID_PTR)("callback")); |
||||
|