[Ace-users] [ace-users] ACE_SOCK_Dgram_Bcast to find server
Robert.Thornthwaite at iongeo.com
Wed Nov 7 21:32:03 CST 2007
> To ensure that we have proper version/platform/compiler
> information, please make sure you fill out the appropriate
> problem report form (PRF),
HOST and TARGET: Redhat Linux Release 4 Update 5
makeinclude/platform_macros.GNU -> platform_linux.GNU
This is an execution question.
> > I am trying to use ACE_SOCK_Dgram_Bcast to find a server
> > device. The server responds to the broadcast on my local
> > port that I sent in the broadcast message. I try to use the
> > same instance of ACE_SOCK_Dgram_Bcast to receive the response
> > but it does not work.
> > I know that if the server responded on a different port
> > than the one I sent, I could use another ACE_SOCK_Dgram
> > opened on that port and read the response. But I can't
> > create another ACE_SOCK_Dgram to read the same local port
> > that the ACE_SOCK_Dgram_Bcast already has open.
> > It seems natural to use the ACE_SOCK_Dgram_Bcast to tell
> > the server what port to respond on. What is the trick?
> There are examples of ACE_SOCK_Dgram_Bcast in
I have looked at these examples. I also have the text books
APG, NPV1, and NPV2. I am trying to use this and other things
with the Reactor but that is not relevant.
Below is a simple example of what I am trying to do.
I verified with WireShark that the broadcast msg is going
Out to port 8888 and responses are being sent back to port 2077.
The recv() just times out.
Should this not work?
/** Start Example */
typedef unsigned short uint16;
int main (int nargs, char ** args)
char* mpSS_IP_RequestMsg ="Passport Networks Inc.";
ACE_INET_Addr mMyAddr(ACE_static_cast (uint16, 2077));
ACE_SOCK_Dgram_Bcast mDgram(mMyAddr,ACE_PROTOCOL_FAMILY_INET,0,1); //
For sending broadcast
ssize_t sent = 0;
ssize_t recvCount = 0;
sent = mDgram.send((char*)mpSS_IP_RequestMsg,
ACE_static_cast (uint16, 8888));
recvCount = 0;
while (recvCount >= 0)
recvCount = mDgram.recv((void*)&serialServerResponse,
mSerialServer_Address, 0, &mtimeout);
if (recvCount < 0)
ACE_DEBUG((LM_DEBUG," Timed out \n"));
else if (recvCount > 0)
ACE_DEBUG((LM_DEBUG," OK \n"));
ACE_DEBUG((LM_DEBUG, " Zero \n"));
/** End Example */
> There are also examples of ACE_SOCK_Dgram_Mcast that might be
> relevant, as well, in
> Finally, TAO has a service that uses multicast to do
> basically what you're trying to achieve. Please see
> for details.
This email and any files transmitted with it are confidential and are intended solely for the use of the individual or entity to whom they are addressed. If you are not the original recipient or the person responsible for delivering the email to the intended recipient, be advised that you have received this email in error, and that any use, dissemination, forwarding, printing, or copying of this email is strictly prohibited. If you received this email in error, please immediately notify the sender and delete the original.
More information about the Ace-users