public function request(): string
    {
        $sock = socket_create(\AF_INET, \SOCK_DGRAM, \SOL_UDP);
        if ($sock === false) {
            throw new NetworkException(socket_strerror(socket_last_error()));
        }

        $level = (int) getprotobyname("ip");

        socket_set_option($sock, $level, \IP_MULTICAST_TTL, 2);

        if ($this->networkInterface !== null) {
            socket_set_option($sock, $level, \IP_MULTICAST_IF, $this->networkInterface);
        }

        $request = "M-SEARCH * HTTP/1.1\r\n";
        $request .= "HOST: {$this->multicastAddress}:reservedSSDPport\r\n";
        $request .= "MAN: ssdp:discover\r\n";
        $request .= "MX: 1\r\n";
        $request .= "ST: urn:schemas-upnp-org:device:ZonePlayer:1\r\n";

        $this->logger->debug($request);

        socket_sendto($sock, $request, strlen($request), 0, $this->multicastAddress, 1900);

        $read = [$sock];
        $write = [];
        $except = [];
        $name = null;
        $port = null;
        $tmp = "";

        $response = "";
        while (socket_select($read, $write, $except, 1)) {
            socket_recvfrom($sock, $tmp, 2048, 0, $name, $port);
            $response .= $tmp;
        }

        $this->logger->debug($response);

        return $response;
    }
public function request(): string
    {
        $sock = socket_create(\AF_INET, \SOCK_DGRAM, \SOL_UDP);
        if ($sock === false) {
            throw new NetworkException(socket_strerror(socket_last_error()));
        }

        $level = (int) getprotobyname("ip");

        socket_set_option($sock, $level, \IP_MULTICAST_TTL, 2);

        if ($this->networkInterface !== null) {
            socket_set_option($sock, $level, \IP_MULTICAST_IF, $this->networkInterface);
        }

        $request = "M-SEARCH * HTTP/1.1\r\n";
        $request .= "HOST: {$this->multicastAddress}:reservedSSDPport\r\n";
        $request .= "MAN: ssdp:discover\r\n";
        $request .= "MX: 1\r\n";
        $request .= "ST: urn:schemas-upnp-org:device:ZonePlayer:1\r\n";

        $this->logger->debug($request);

        socket_sendto($sock, $request, strlen($request), 0, $this->multicastAddress, 1900);

        $read = [$sock];
        $write = [];
        $except = [];
        $name = null;
        $port = null;
        $tmp = "";

        $response = "";
        while (socket_select($read, $write, $except, 1)) {
            socket_recvfrom($sock, $tmp, 2048, 0, $name, $port);
            $response .= $tmp;
        }

        $this->logger->debug($response);

        return $response;
    }
public function request ( ) : string { $ sock = socket_create ( \ AF_INET , \ SOCK_DGRAM , \ SOL_UDP ) ; if ( $ sock === false ) { throw new NetworkException ( socket_strerror ( socket_last_error ( ) ) ) ; } $ level = ( int ) getprotobyname ( "ip" ) ; socket_set_option ( $ sock , $ level , \ IP_MULTICAST_TTL , 2 ) ; if ( $ this -> networkInterface !== null ) { socket_set_option ( $ sock , $ level , \ IP_MULTICAST_IF , $ this -> networkInterface ) ; } $ request = "M-SEARCH * HTTP/1.1\r\n" ; $ request .= "HOST: {$this->multicastAddress}:reservedSSDPport\r\n" ; $ request .= "MAN: ssdp:discover\r\n" ; $ request .= "MX: 1\r\n" ; $ request .= "ST: urn:schemas-upnp-org:device:ZonePlayer:1\r\n" ; $ this -> logger -> debug ( $ request ) ; socket_sendto ( $ sock , $ request , strlen ( $ request ) , 0 , $ this -> multicastAddress , 1900 ) ; $ read = [ $ sock ] ; $ write = [ ] ; $ except = [ ] ; $ name = null ; $ port = null ; $ tmp = "" ; $ response = "" ; while ( socket_select ( $ read , $ write , $ except , 1 ) ) { socket_recvfrom ( $ sock , $ tmp , 2048 , 0 , $ name , $ port ) ; $ response .= $ tmp ; } $ this -> logger -> debug ( $ response ) ; return $ response ; }
Send out the multicast discover request.

@return string
@throws NetworkException
Send out the multicast discover request .