CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 1999
    Location
    Madurai, Tamil Nadu, INDIA
    Posts
    5

    MFC - CSocket & CAsyncSocket

    How to broadcast data using MFC (either with CSocket/CAsyncSocket)?
    Pl.give a detailed explanation.URGENT
    mail id : [email protected]


  2. #2
    Join Date
    May 1999
    Posts
    45

    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
  •  





Click Here to Expand Forum to Full Width

Featured