|
-
May 18th, 1999, 08:56 AM
#1
MFC - CSocket & CAsyncSocket
How to broadcast data using MFC (either with CSocket/CAsyncSocket)?
Pl.give a detailed explanation.URGENT
mail id : [email protected]
-
May 18th, 1999, 09:45 AM
#2
Re: MFC - CSocket & CAsyncSocket
The only "trick" to setting a socket up for broadcast is setting the socket option. Here is a snippet of code to do that:
return_code = CAsyncSocket::Create( 3000, SOCK_DGRAM, FD_READ | FD_CLOSE, NULL );
if( return_code == TRUE )
{
int sock_opt_value = 1;
return_code = CAsyncSocket::SetSockOpt( SO_BROADCAST, &sock_opt_value, sizeof( BOOL ), SOL_SOCKET );
}
I picked 3000 as the port number to broadcast on in the Create function just because it seemed like a nice high number.
That's about all there is to it.
Dan
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|