Are there any specific PHP functions or libraries that are recommended for creating a tool that scans a LAN for game servers?

To create a tool that scans a LAN for game servers using PHP, you can utilize the `fsockopen` function to establish a connection to each potential game server's IP address and port. By iterating through a range of IP addresses within the LAN and checking for open ports commonly used by game servers, you can identify active game servers on the network.

<?php
// Define the range of IP addresses to scan within the LAN
$ip_range = range('192.168.1.1', '192.168.1.255');

// Define the ports commonly used by game servers
$ports = [27015, 27016, 27017];

foreach ($ip_range as $ip) {
    foreach ($ports as $port) {
        $connection = @fsockopen($ip, $port, $errno, $errstr, 1);
        if ($connection) {
            echo "Game server found at $ip:$port\n";
            fclose($connection);
        }
    }
}
?>