php - 连接到udp服务器

I am about to write a function which returns true or false. If the function is able to connect to the game server (doesn't need anything further, just to check if it's running) via UDP and a specific ip, it'll return true. If not, it'll return false. Unfortunately, I didn't find anything useful by searching the web.

Edit: For TCP, I'm using this and it's working like a charm.

function loginServer()
    {
            $ipAddr = "localhost";
            $port = 1234;
            $fp = fsockopen($ipAddr, $port, $errno, $errstr);
            if(!$fp)
            {
                    return false;
            }
            else 
            {
                    fclose($fp);
                    return true;
            }
    }