cmRtNet.h/c:Added cmRtNetLocalHostName(). Replaced use of cmUdpHostNameXXX() w/ cmUdpHostName() in cmRtNetTest().
This commit is contained in:
parent
875fce5f9d
commit
bb1e86f9de
16
cmRtNet.c
16
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; }
|
||||||
|
|
||||||
@ -854,15 +861,12 @@ void cmRtNetTest( cmCtx_t* ctx, bool mstrFl )
|
|||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
_cmRtNetTest_t t;
|
_cmRtNetTest_t t;
|
||||||
|
const cmChar_t* hostNameStr;
|
||||||
cmUdpPort_t port = 5876;
|
cmUdpPort_t port = 5876;
|
||||||
_cmRtNetTest_t* p = &t;
|
_cmRtNetTest_t* p = &t;
|
||||||
cmRtNetRC_t rc = kOkNetRC;
|
cmRtNetRC_t rc = kOkNetRC;
|
||||||
unsigned hn = cmUdpHostNameMaxCharCount();
|
|
||||||
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user