Click to See Complete Forum and Search --> : CSocket::SendTo returns error when broadcasts???


bsmanoj
March 30th, 1999, 05:00 AM
Hi all,

When I used CSocket::SendTo(), with broadcast address(all 1s)

it returns the following error:

WSAEACCES The requested address is a broadcast address, but the appropriate flag was not set.

Then I used the flag MSG_DONTROUTE in sendTo function then also the same error is returned.

Then I tried with MSG_DONTROUTE|SO_DONTROUTE then it returned WSAEOPNOTSUPP.

Can any body tell me which flag should I use to broadcast an IP packet using CSocket.

thanks in advance.

bsmanoj

Mats Bejedahl
March 31st, 1999, 07:24 AM
Hi,


YouŽll need to set a socket option to enable broadcast.


BOOL bEnableBroadcast(TRUE);

Socket.SetSockOpt(SO_BROADCAST, (const void*)&bEnableBroadcast, sizeof(BOOL));


/Mats Bejedahl

bsmanoj
April 1st, 1999, 11:39 AM
Dear mat,

Thanks a lot. It worked.

bsmanoj