Quantcast
Channel: VMware Communities : Popular Discussions - VIX API
Viewing all articles
Browse latest Browse all 34639

VixHost_Connect intermittent operation

$
0
0

I find the VixHost_Connect sometimes connects, or sometimes fails with VIX_E_FAIL:

 

code:

 

extern "C" {

#include "vix.h"

}

 

#include

using namespace std;

 

class VixHost ;

 

VixHost::VixHost(){

     handle = VIX_INVALID_HANDLE;

}

 

bool VixHost::open(const char *host, int port, const char *username, const char *password){

 

     VixHandle job_handle = VIX_INVALID_HANDLE;

     VixError err;

 

     job_handle = VixHost_Connect(VIX_API_VERSION,

                                        VIX_SERVICEPROVIDER_VMWARE_SERVER,

                                        host,

                                        port,

                                        username,

                                        password,

                                        0,

                                        VIX_INVALID_HANDLE,

                                        0,

                                        0);

 

     err = VixJob_Wait(job_handle,

                              VIX_PROPERTY_JOB_RESULT_HANDLE,

                              &handle,

                              VIX_PROPERTY_NONE);

 

     Vix_ReleaseHandle(job_handle);

 

     if (VIX_OK != err) {

          cerr << "VixHost::open error code: " << err << endl;

          error_code = VIX_ERROR_CODE(err);

          return false;

     }

 

     error_code = 0;

     return true;

}

 

VixHost::~VixHost(){

     Vix_ReleaseHandle(handle);

}

 

void VixHost::close(){

     Vix_ReleaseHandle(handle);

     handle = VIX_INVALID_HANDLE;

}

 

#define USERNAME "username"

#define PASSWORD "password"

 

int main(){

     VixHost host;

     for (int i = 0; i < 10; i++) {

          if (host.open("localhost", 902, USERNAME, PASSWORD)){

               cout << "connected!" << endl;

          }

          host.close();

     }

}

 

 

result:

 

\[julian@dual-opteron Debug]$ ./vix

connected!

VixHost::open error code: 1

VixHost::open error code: 1

VixHost::open error code: 1

VixHost::open error code: 1

VixHost::open error code: 1

VixHost::open error code: 1

VixHost::open error code: 1

VixHost::open error code: 1

VixHost::open error code: 1

\[julian@dual-opteron Debug]$ ./vix

connected!

connected!

connected!

connected!

connected!

connected!

connected!

connected!

connected!

connected!

 

Does anybody else see this problem?


Viewing all articles
Browse latest Browse all 34639

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>