Can't get a session using HAPI_CreateThriftNamedPipeSession.

   4209   2   0
User Avatar
Member
21 posts
Joined: Feb. 2011
Offline
I've been trying to create a HE session using HAPI_CreateThriftNamedPipeSession() using the following code snippet but the session is always undefined. The HARS server gets started ok.

What am I failing to do in order to get a valid session?

HAPI_Session *session;
std:stringstream pipe_name_os;
pipe_name_os << “HE_Session” << ‘_’ << GetCurrentProcessId();
const std::string pipe_name = pipe_name_os.str();

HAPI_StartThriftNamedPipeServer( true, pipe_name.c_str(), 5000, NULL );

HAPI_CreateThriftNamedPipeSession(session, pipe_name.c_str() );


I also tried using the HAPI_StartThriftSocketServer and HAPI_CreateThriftSocketSession functions and still cannot get a session created.

I also tried starting a HARS Server manually and using netstat can see that my port specified is in a listening mode. I then tried to specify that port in the
HAPI_CreateThriftSocketSession function but the session is still undefined.

It would have been nice to have a complete working sample to show how to use the new session functions.
User Avatar
Member
402 posts
Joined: March 2013
Offline
The session parameter for HAPI_CreateThriftNamedPipeSession() needs to be a pointer to an already allocated HAPI_Session struct object. So, if you just change the lines from:

HAPI_Session *session;

HAPI_CreateThriftNamedPipeSession(session, pipe_name.c_str() );

to:

HAPI_Session session;

HAPI_CreateThriftNamedPipeSession(&session, pipe_name.c_str() );

it should work.

HAPI never allocates memory for you. It will only fill memory you allocated yourself and gave a pointer to. In other words, any non-const pointer parameters you see expect an actual object to be initialized and do not return a new pointer.
User Avatar
Member
21 posts
Joined: Feb. 2011
Offline
Ok, I got it working.

Thanks for the info damian.
  • Quick Links