Здравствуйте!
Код:
$sock = @fsockopen( "udp://" . $ip, $port );
if( !$sock ) exit( "error connect" );
$challengePacketHeader = "\xff\xff\xff\xff\x73\x0a";
$challenge = mt_rand( 0, 2 ** 32 - 1 );
$packet = $challengePacketHeader;
$packet .= pack( "I", $challenge );
fputs( $sock, $packet, strlen( $packet ) );
$output = fread( $sock, true );
fclose( $sock );
Всё взято с python:
challengePacketHeader = b'\xff\xff\xff\xff\x73\x0a'
challenge = random.randint(0, 2**32-1)
packet = challengePacketHeader
packet += pack('I', challenge)
self.sock.sendto(packet, addr)