Ping broadcast on Win XP SP3

Posted by PaulH on Stack Overflow See other posts from Stack Overflow or by PaulH
Published on 2011-01-14T21:50:20Z Indexed on 2011/01/14 21:53 UTC
Read the original article Hit count: 229

Filed under:
|
|
|

I'm trying to ping the broadcast address 255.255.255.255 on WinXP SP3.

If I use the command line, I get host error:

C:\>ping 255.255.255.255
Ping request could not find host 255.255.255.255. Please check the name and try again.

If I try a C++ program using the iphlpapi, IcmpSendEcho() fails and GetLastError returns 11010 IP_REQ_TIMED_OUT.

HANDLE h = ::IcmpCreateFile();
IPAddr broadcast = inet_addr( "255.255.255.255" );
BYTE payload[ 32 ] = { 0 };
IP_OPTION_INFORMATION option = { 255, 0, 0, 0, 0 };

// a buffer with room for 32 replies each containing the full payload
std::vector< BYTE > replies( 32 * ( sizeof( ICMP_ECHO_REPLY ) + 32 ) );

DWORD res = ::IcmpSendEcho( h, 
                            broadcast, 
                            payload, 
                            sizeof( payload ), 
                            &option, 
                            &replies[ 0 ], 
                            replies.size(), 
                            1000 );
::IcmpCloseHandle( h );

I can ping the local broadcast 192.168.0.255 with no problem.

What do I need to do to ping the global broadcast?

Thanks, PaulH

© Stack Overflow or respective owner

Related posts about c++

Related posts about networking