diff --git a/examples/normCast.cpp b/examples/normCast.cpp index 381b7e6..e280337 100755 --- a/examples/normCast.cpp +++ b/examples/normCast.cpp @@ -89,6 +89,14 @@ class NormCaster assert(NORM_SESSION_INVALID != norm_session); NormSetMulticastInterface(norm_session, ifaceName); } + bool SetNormTxPort(UINT16 txPort, + bool enableReuse, + const char* txAddress) + { + assert(NORM_SESSION_INVALID != norm_session); + return NormSetTxPort(norm_session, txPort, enableReuse, txAddress); + + } void SetLoopback(bool state) { loopback = state; @@ -887,7 +895,8 @@ void Usage() { fprintf(stderr, "Usage: normCast {send &| recv } [silent {on|off}]\n" " [repeat [updatesOnly]] [id ]\n" - " [addr [/]] [interface ] [loopback]\n" + " [addr [/]] [txAddr [/]]\n" + " [interface ] [loopback]\n" " [ack auto|[,,...]] [segment ]\n" " [block ] [parity ] [auto ]\n" " [cc|cce|ccl|rate ] [rxloss ]\n" @@ -913,6 +922,12 @@ int main(int argc, char* argv[]) char sessionAddr[64]; strcpy(sessionAddr, "224.1.2.3"); unsigned int sessionPort = 6003; + + char sessionTxAddr[64]; + strcpy(sessionTxAddr, ""); + unsigned int sessionTxPort = 0; + + bool autoAck = false; NormNodeId ackingNodeList[256]; @@ -1053,6 +1068,26 @@ int main(int argc, char* argv[]) sessionPort = atoi(portPtr); } } + else if (0 == strncmp(cmd, "txAddr", len)) + { + const char* addrPtr = argv[i++]; + const char* portPtr = strchr(addrPtr, '/'); + if (NULL == portPtr) + { + strncpy(sessionTxAddr, addrPtr, 63); + sessionTxAddr[63] = '\0'; + } + else + { + size_t addrLen = portPtr - addrPtr; + if (addrLen > 63) addrLen = 63; // should issue error message + strncpy(sessionTxAddr, addrPtr, addrLen); + sessionTxAddr[addrLen] = '\0'; + portPtr++; + sessionTxPort = atoi(portPtr); + } + } + else if (0 == strncmp(cmd, "id", len)) { if (i >= argc) @@ -1512,6 +1547,9 @@ int main(int argc, char* argv[]) normCast.SetNormTxRate(txRate); if (NULL != mcastIface) normCast.SetNormMulticastInterface(mcastIface); + if (NULL != sessionTxAddr) { + normCast.SetNormSetTxPort(sessionTxPort, true, sessionTxAddr); + } if (trace) normCast.SetNormMessageTrace(true);