From 76258fe7e2ed212009c7607209ce8ddfddd51dc8 Mon Sep 17 00:00:00 2001 From: kpl Date: Sat, 27 Apr 2013 15:51:58 -0700 Subject: [PATCH] cmUdpPort.h/c: Added kBroadcastUdpFl option. --- cmUdpPort.c | 12 ++++++++++++ cmUdpPort.h | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) 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 };