cmRtNet.h/c:Added cmRtNetLocalHostName(). Replaced use of cmUdpHostNameXXX() w/ cmUdpHostName() in cmRtNetTest().

This commit is contained in:
kpl 2013-04-27 12:14:58 -07:00
parent 875fce5f9d
commit bb1e86f9de
2 changed files with 20 additions and 10 deletions

View File

@ -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 = "<no-host-name>";
if((rc = cmRtNetCreateNode(p->netH, hostNameStr, NULL, port )) != kOkNetRC)
goto errLabel;

View File

@ -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