CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 1999
    Posts
    18

    CSocket::SendTo returns error when broadcasts???



    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





  2. #2
    Join Date
    Mar 1999
    Posts
    3

    Re: CSocket::SendTo returns error when broadcasts???



    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

  3. #3
    Join Date
    Apr 1999
    Posts
    18

    Thanks It worked CSocket::SendTo returns error when broadcasts???



    Dear mat,

    Thanks a lot. It worked.

    bsmanoj

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