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.
Can't get a session using HAPI_CreateThriftNamedPipeSession.
4209 2 0- gwcSoftware
- Member
- 21 posts
- Joined: Feb. 2011
- Offline
- damian
- 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.
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.
- gwcSoftware
- Member
- 21 posts
- Joined: Feb. 2011
- Offline
-
- Quick Links