cmRtNet.h/c:Added cmRtNetIsInitialized() and check for non-blank node label and bcast address.
This commit is contained in:
parent
85e1b90c14
commit
e8e3f189ed
21
cmRtNet.c
21
cmRtNet.c
@ -4,10 +4,12 @@
|
||||
#include "cmCtx.h"
|
||||
#include "cmMem.h"
|
||||
#include "cmMallocDebug.h"
|
||||
#include "cmLinkedHeap.h"
|
||||
#include "cmUdpPort.h"
|
||||
#include "cmRtNet.h"
|
||||
#include "cmTime.h"
|
||||
#include "cmRtSysMsg.h"
|
||||
#include "cmText.h"
|
||||
|
||||
// flags for cmRtNetNode_t.flags;
|
||||
enum
|
||||
@ -193,7 +195,7 @@ cmRtNetRC_t _cmRtNetCreateNode( cmRtNet_t* p, const cmChar_t* label, const cmCha
|
||||
cmRtNetRC_t rc = kOkNetRC;
|
||||
cmRtNetNode_t* np;
|
||||
|
||||
if( label == NULL )
|
||||
if( cmTextIsEmpty(label) )
|
||||
return cmErrMsg(&p->err,kInvalidLabelNetRC,"A null or blank node label was encountered.");
|
||||
|
||||
if((np = _cmRtNetFindNode(p,label)) != NULL )
|
||||
@ -620,6 +622,12 @@ cmRtNetRC_t cmRtNetInitialize( cmRtNetH_t h, const cmChar_t* bcastAddr, const cm
|
||||
if((rc = cmRtNetFinalize(h)) != kOkNetRC )
|
||||
goto errLabel;
|
||||
|
||||
if( cmTextIsEmpty(bcastAddr) )
|
||||
{
|
||||
rc = cmErrMsg(&p->err,kInvalidArgNetRC,"The 'broadcast address' is not valid.");
|
||||
goto errLabel;
|
||||
}
|
||||
|
||||
// if this is the local node then initialze the local socket
|
||||
if( cmUdpInit(p->udpH,port,kNonBlockingUdpFl | kBroadcastUdpFl,_cmRtNetRecv,p,NULL,0,p->udpRecvBufByteCnt,p->udpTimeOutMs) != kOkUdpRC )
|
||||
{
|
||||
@ -647,6 +655,17 @@ cmRtNetRC_t cmRtNetInitialize( cmRtNetH_t h, const cmChar_t* bcastAddr, const cm
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
bool cmRtNetIsInitialized( cmRtNetH_t h )
|
||||
{
|
||||
if( cmRtNetIsValid(h) == false )
|
||||
return false;
|
||||
|
||||
cmRtNet_t* p = _cmRtNetHandleToPtr(h);
|
||||
return p->localNode != NULL && cmTextIsNotEmpty(p->bcastAddr);
|
||||
}
|
||||
|
||||
|
||||
cmRtNetRC_t cmRtNetRegisterEndPoint( cmRtNetH_t h, const cmChar_t* endPtLabel, unsigned endPtId )
|
||||
{
|
||||
cmRtNetRC_t rc = kOkNetRC;
|
||||
|
@ -18,6 +18,7 @@ extern "C" {
|
||||
kNodeNotFoundNetRC,
|
||||
kEndNotFoundNetRC,
|
||||
kLocalNodeNetRC,
|
||||
kInvalidArgNetRC,
|
||||
kSyncFailNetRC,
|
||||
kNodeEndCntErrNetRC
|
||||
};
|
||||
@ -47,6 +48,7 @@ extern "C" {
|
||||
// 'ipPort' refers to the socket port (which may need to be made available
|
||||
// by the machine firewall cfg.)
|
||||
cmRtNetRC_t cmRtNetInitialize( cmRtNetH_t h, const cmChar_t* bcastAddr, const cmChar_t* nodeLabel, const cmChar_t* ipAddr, cmUdpPort_t ipPort );
|
||||
bool cmRtNetIsInitialized( cmRtNetH_t h );
|
||||
|
||||
// Register the local endpoints.
|
||||
// Endpoints may only be registered once the network is initialized via
|
||||
|
Loading…
Reference in New Issue
Block a user