public static function dial($addr)
    {
        $socket = stream_socket_client('tcp://' . $addr);
        if ($socket === false) {
            throw new Exception('Could not dial to ' . $addr . ': ' . socket_strerror(socket_last_error()));
        }
        return $socket;
    }