PaulH
PaulH

Reputation: 7853

Ping broadcast on Win XP SP3

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

Upvotes: 0

Views: 2969

Answers (2)

user207421
user207421

Reputation: 310893

Broadcast UDP has been obsolete for about 20 years. It is most unlikely to get through a router to another subnet.

Upvotes: 0

Kirill V. Lyadvinsky
Kirill V. Lyadvinsky

Reputation: 99585

This doesn't work in Windows as I know. In Linux OS you can ping 255.255.255.255, but routing protocol will not relay 255.255.255.255 broadcasts outside of the local network.

What are you trying to achieve? Are you ready that every computer on the connected earth will respond? I'm scared...


By the way, you should be ready that no one will respond to the broadcast ping even in the local network. This question on SF could be useful.

Upvotes: 3

Related Questions