Connect

The Connect method connects a process to the instrumentation server at the specified socket address and port.

Signature
int RiCOSConnectionPort_Connect(
   RiCOSConnectionPort *const me, 
   const char* const SocketAddress,
   unsigned int nSocketPort);
Parameters
me

The RiCOSConnectionPort object.

SocketAddress

The socket address. The default value is NULL.

nSocketPort

The port number of the socket. The default value is 0.

Returns

The connection status. The possible values are as follows:

Example
RiCOSResult RiCOSConnectionPort_Connect(
   RiCOSConnectionPort * const me,
   const char* const SocketAddress,
   unsigned int nSocketPort)
{
   if (me==NULL) return 0;

   if (NULL == me->m_dispatchfunc) {
      fprintf(stderr, "RiCOSConnectionPort_SetDispatcher 
      is called before
      RiCOSConnectionPort_Connect()\n");
      return 0;
   }

   if ( 0  == me->m_Connected ) {
      (void)RiCOSSocket_init(&me->m_Socket);
      me->m_Connected = RiCOSSocket_createSocket(
         &me->m_Socket,SocketAddress,nSocketPort);
   }

   if (0 == me->m_Connected)
      return 0;

   /* Connection established invoking thread to 
      receive messages from the socket */   
   
   me->m_ConnectionThread = RiCOSTask_create((
      void (*)(void *))readFromSockLoop,
      (void *)me,"tRhpSock",RiCOSDefaultStackSize);
   RiCOSTask_start(me->m_ConnectionThread);
   return me->m_Connected;
}

Feedback