Browse Source

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

master
kpl 11 years ago
parent
commit
bb1e86f9de
2 changed files with 20 additions and 10 deletions
  1. 17
    9
      cmRtNet.c
  2. 3
    1
      cmRtNet.h

+ 17
- 9
cmRtNet.c View File

@@ -415,6 +415,13 @@ cmRtNetRC_t cmRtNetFree( cmRtNetH_t* hp )
415 415
   return rc;
416 416
 }
417 417
 
418
+const cmChar_t* cmRtNetLocalHostName( cmRtNetH_t h )
419
+{
420
+  cmRtNet_t*  p = _cmRtNetHandleToPtr(h);
421
+  return cmUdpHostName(p->udpH);
422
+}
423
+
424
+
418 425
 bool cmRtNetIsValid( cmRtNetH_t h )
419 426
 { return h.h !=NULL; }
420 427
 
@@ -852,17 +859,14 @@ bool _cmRtNetTestThreadFunc(void* param)
852 859
 
853 860
 void  cmRtNetTest( cmCtx_t* ctx, bool mstrFl )
854 861
 {
855
-  char c;
856
-  _cmRtNetTest_t t;
857
-  cmUdpPort_t port = 5876;
858
-  _cmRtNetTest_t* p = &t;
859
-  cmRtNetRC_t rc = kOkNetRC;
860
-  unsigned hn = cmUdpHostNameMaxCharCount();
861
-  cmChar_t hostNameStr[ hn ];
862
+  char            c;
863
+  _cmRtNetTest_t  t;
864
+  const cmChar_t* hostNameStr;
865
+  cmUdpPort_t     port = 5876;
866
+  _cmRtNetTest_t* p    = &t;
867
+  cmRtNetRC_t     rc   = kOkNetRC;
862 868
   memset(&t,0,sizeof(t));
863 869
 
864
-  if( cmUdpHostName(hostNameStr,hn) != kOkUdpRC )
865
-    goto errLabel;
866 870
 
867 871
   if( cmThreadCreate(&p->thH,_cmRtNetTestThreadFunc,p,&ctx->rpt) != kOkThRC )
868 872
     goto errLabel;
@@ -870,6 +874,10 @@ void  cmRtNetTest( cmCtx_t* ctx, bool mstrFl )
870 874
   if((rc = cmRtNetAlloc(ctx,&p->netH,_cmRtNetTestRecv,p)) != kOkNetRC )
871 875
     goto errLabel;
872 876
 
877
+  hostNameStr = cmRtNetLocalHostName(p->netH);
878
+  if( hostNameStr == NULL )
879
+    hostNameStr = "<no-host-name>";
880
+
873 881
   if((rc = cmRtNetCreateNode(p->netH, hostNameStr, NULL, port )) != kOkNetRC)
874 882
     goto errLabel;
875 883
 

+ 3
- 1
cmRtNet.h View File

@@ -34,6 +34,7 @@ extern "C" {
34 34
 
35 35
   bool      cmRtNetIsValid( cmRtNetH_t h );
36 36
 
37
+  const cmChar_t* cmRtNetLocalHostName( cmRtNetH_t h );
37 38
 
38 39
   // Create a network node.
39 40
   // The 'nodeLabel' refers to a network device cfg. (see cmDevCfg).
@@ -42,6 +43,7 @@ extern "C" {
42 43
   // nodes in the node list.
43 44
   cmRtNetRC_t cmRtNetCreateNode( cmRtNetH_t h, const cmChar_t* nodeLabel, const cmChar_t* ipAddr, cmUdpPort_t ipPort );
44 45
 
46
+
45 47
   // Register the local endpoints.
46 48
   // Remote nodes will be able to send messages to these endpoints by
47 49
   // referring to (nodeLabel/endPtLabel)
@@ -61,7 +63,7 @@ extern "C" {
61 63
   // an endpoint it updates it's own remote node/endpoint 
62 64
   // list.
63 65
   cmRtNetRC_t cmRtNetBeginSyncMode( cmRtNetH_t h );
64
-  bool      cmRtNetIsInSyncMode(  cmRtNetH_t h );
66
+  bool        cmRtNetIsInSyncMode(  cmRtNetH_t h );
65 67
 
66 68
   // When the network message recieve function (See cmRtNetAlloc() 'cbFunc') 
67 69
   // receives a message with the cmRtSysMsgHdr_t.selId == kNetSyncSelRtId

Loading…
Cancel
Save