diff --git a/cmRtNet.c b/cmRtNet.c index acff8a0..fccd7e5 100644 --- a/cmRtNet.c +++ b/cmRtNet.c @@ -415,6 +415,13 @@ cmRtNetRC_t cmRtNetFree( cmRtNetH_t* hp ) return rc; } +const cmChar_t* cmRtNetLocalHostName( cmRtNetH_t h ) +{ + cmRtNet_t* p = _cmRtNetHandleToPtr(h); + return cmUdpHostName(p->udpH); +} + + bool cmRtNetIsValid( cmRtNetH_t h ) { return h.h !=NULL; } @@ -852,17 +859,14 @@ bool _cmRtNetTestThreadFunc(void* param) void cmRtNetTest( cmCtx_t* ctx, bool mstrFl ) { - char c; - _cmRtNetTest_t t; - cmUdpPort_t port = 5876; - _cmRtNetTest_t* p = &t; - cmRtNetRC_t rc = kOkNetRC; - unsigned hn = cmUdpHostNameMaxCharCount(); - cmChar_t hostNameStr[ hn ]; + char c; + _cmRtNetTest_t t; + const cmChar_t* hostNameStr; + cmUdpPort_t port = 5876; + _cmRtNetTest_t* p = &t; + cmRtNetRC_t rc = kOkNetRC; memset(&t,0,sizeof(t)); - if( cmUdpHostName(hostNameStr,hn) != kOkUdpRC ) - goto errLabel; if( cmThreadCreate(&p->thH,_cmRtNetTestThreadFunc,p,&ctx->rpt) != kOkThRC ) goto errLabel; @@ -870,6 +874,10 @@ void cmRtNetTest( cmCtx_t* ctx, bool mstrFl ) if((rc = cmRtNetAlloc(ctx,&p->netH,_cmRtNetTestRecv,p)) != kOkNetRC ) goto errLabel; + hostNameStr = cmRtNetLocalHostName(p->netH); + if( hostNameStr == NULL ) + hostNameStr = ""; + if((rc = cmRtNetCreateNode(p->netH, hostNameStr, NULL, port )) != kOkNetRC) goto errLabel; diff --git a/cmRtNet.h b/cmRtNet.h index 0939cdc..769ea98 100644 --- a/cmRtNet.h +++ b/cmRtNet.h @@ -34,6 +34,7 @@ extern "C" { bool cmRtNetIsValid( cmRtNetH_t h ); + const cmChar_t* cmRtNetLocalHostName( cmRtNetH_t h ); // Create a network node. // The 'nodeLabel' refers to a network device cfg. (see cmDevCfg). @@ -42,6 +43,7 @@ extern "C" { // nodes in the node list. cmRtNetRC_t cmRtNetCreateNode( cmRtNetH_t h, const cmChar_t* nodeLabel, const cmChar_t* ipAddr, cmUdpPort_t ipPort ); + // Register the local endpoints. // Remote nodes will be able to send messages to these endpoints by // referring to (nodeLabel/endPtLabel) @@ -61,7 +63,7 @@ extern "C" { // an endpoint it updates it's own remote node/endpoint // list. cmRtNetRC_t cmRtNetBeginSyncMode( cmRtNetH_t h ); - bool cmRtNetIsInSyncMode( cmRtNetH_t h ); + bool cmRtNetIsInSyncMode( cmRtNetH_t h ); // When the network message recieve function (See cmRtNetAlloc() 'cbFunc') // receives a message with the cmRtSysMsgHdr_t.selId == kNetSyncSelRtId