cmRtNet.h/c:Added cmRtNetLocalHostName(). Replaced use of cmUdpHostNameXXX() w/ cmUdpHostName() in cmRtNetTest().
This commit is contained in:
parent
875fce5f9d
commit
bb1e86f9de
26
cmRtNet.c
26
cmRtNet.c
@ -415,6 +415,13 @@ cmRtNetRC_t cmRtNetFree( cmRtNetH_t* hp )
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const cmChar_t* cmRtNetLocalHostName( cmRtNetH_t h )
|
||||||
|
{
|
||||||
|
cmRtNet_t* p = _cmRtNetHandleToPtr(h);
|
||||||
|
return cmUdpHostName(p->udpH);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool cmRtNetIsValid( cmRtNetH_t h )
|
bool cmRtNetIsValid( cmRtNetH_t h )
|
||||||
{ return h.h !=NULL; }
|
{ return h.h !=NULL; }
|
||||||
|
|
||||||
@ -852,17 +859,14 @@ bool _cmRtNetTestThreadFunc(void* param)
|
|||||||
|
|
||||||
void cmRtNetTest( cmCtx_t* ctx, bool mstrFl )
|
void cmRtNetTest( cmCtx_t* ctx, bool mstrFl )
|
||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
_cmRtNetTest_t t;
|
_cmRtNetTest_t t;
|
||||||
cmUdpPort_t port = 5876;
|
const cmChar_t* hostNameStr;
|
||||||
_cmRtNetTest_t* p = &t;
|
cmUdpPort_t port = 5876;
|
||||||
cmRtNetRC_t rc = kOkNetRC;
|
_cmRtNetTest_t* p = &t;
|
||||||
unsigned hn = cmUdpHostNameMaxCharCount();
|
cmRtNetRC_t rc = kOkNetRC;
|
||||||
cmChar_t hostNameStr[ hn ];
|
|
||||||
memset(&t,0,sizeof(t));
|
memset(&t,0,sizeof(t));
|
||||||
|
|
||||||
if( cmUdpHostName(hostNameStr,hn) != kOkUdpRC )
|
|
||||||
goto errLabel;
|
|
||||||
|
|
||||||
if( cmThreadCreate(&p->thH,_cmRtNetTestThreadFunc,p,&ctx->rpt) != kOkThRC )
|
if( cmThreadCreate(&p->thH,_cmRtNetTestThreadFunc,p,&ctx->rpt) != kOkThRC )
|
||||||
goto errLabel;
|
goto errLabel;
|
||||||
@ -870,6 +874,10 @@ void cmRtNetTest( cmCtx_t* ctx, bool mstrFl )
|
|||||||
if((rc = cmRtNetAlloc(ctx,&p->netH,_cmRtNetTestRecv,p)) != kOkNetRC )
|
if((rc = cmRtNetAlloc(ctx,&p->netH,_cmRtNetTestRecv,p)) != kOkNetRC )
|
||||||
goto errLabel;
|
goto errLabel;
|
||||||
|
|
||||||
|
hostNameStr = cmRtNetLocalHostName(p->netH);
|
||||||
|
if( hostNameStr == NULL )
|
||||||
|
hostNameStr = "<no-host-name>";
|
||||||
|
|
||||||
if((rc = cmRtNetCreateNode(p->netH, hostNameStr, NULL, port )) != kOkNetRC)
|
if((rc = cmRtNetCreateNode(p->netH, hostNameStr, NULL, port )) != kOkNetRC)
|
||||||
goto errLabel;
|
goto errLabel;
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ extern "C" {
|
|||||||
|
|
||||||
bool cmRtNetIsValid( cmRtNetH_t h );
|
bool cmRtNetIsValid( cmRtNetH_t h );
|
||||||
|
|
||||||
|
const cmChar_t* cmRtNetLocalHostName( cmRtNetH_t h );
|
||||||
|
|
||||||
// Create a network node.
|
// Create a network node.
|
||||||
// The 'nodeLabel' refers to a network device cfg. (see cmDevCfg).
|
// The 'nodeLabel' refers to a network device cfg. (see cmDevCfg).
|
||||||
@ -42,6 +43,7 @@ extern "C" {
|
|||||||
// nodes in the node list.
|
// nodes in the node list.
|
||||||
cmRtNetRC_t cmRtNetCreateNode( cmRtNetH_t h, const cmChar_t* nodeLabel, const cmChar_t* ipAddr, cmUdpPort_t ipPort );
|
cmRtNetRC_t cmRtNetCreateNode( cmRtNetH_t h, const cmChar_t* nodeLabel, const cmChar_t* ipAddr, cmUdpPort_t ipPort );
|
||||||
|
|
||||||
|
|
||||||
// Register the local endpoints.
|
// Register the local endpoints.
|
||||||
// Remote nodes will be able to send messages to these endpoints by
|
// Remote nodes will be able to send messages to these endpoints by
|
||||||
// referring to (nodeLabel/endPtLabel)
|
// referring to (nodeLabel/endPtLabel)
|
||||||
@ -61,7 +63,7 @@ extern "C" {
|
|||||||
// an endpoint it updates it's own remote node/endpoint
|
// an endpoint it updates it's own remote node/endpoint
|
||||||
// list.
|
// list.
|
||||||
cmRtNetRC_t cmRtNetBeginSyncMode( cmRtNetH_t h );
|
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')
|
// When the network message recieve function (See cmRtNetAlloc() 'cbFunc')
|
||||||
// receives a message with the cmRtSysMsgHdr_t.selId == kNetSyncSelRtId
|
// receives a message with the cmRtSysMsgHdr_t.selId == kNetSyncSelRtId
|
||||||
|
Loading…
Reference in New Issue
Block a user