diff --git a/cmUdpPort.c b/cmUdpPort.c index 0c430f1..0048fbe 100644 --- a/cmUdpPort.c +++ b/cmUdpPort.c @@ -256,6 +256,18 @@ cmUdpRC_t cmUdpInit( } + // if broadcast option was requested. + if( cmIsFlag(flags,kBroadcastUdpFl) ) + { + int bcastFl = 1; + if( setsockopt( p->sockH, SOL_SOCKET, SO_BROADCAST, &bcastFl, sizeof(bcastFl) ) == cmUdp_SYS_ERR ) + { + rc = cmErrSysMsg(&p->err,kSockOptSetFailUdpRC,errno, "Attempt to set the socket broadcast attribute failed." ); + goto errLabel; + } + + } + if( recvBufByteCnt != 0 ) p->tempBuf = cmMemAlloc(char,recvBufByteCnt ); diff --git a/cmUdpPort.h b/cmUdpPort.h index e655395..53a36f3 100644 --- a/cmUdpPort.h +++ b/cmUdpPort.h @@ -41,7 +41,8 @@ extern "C" { { kNonBlockingUdpFl = 0x00, kBlockingUdpFl = 0x01, - kNoQueueUdpFl = 0x02 + kNoQueueUdpFl = 0x02, + kBroadcastUdpFl = 0x04 };