private void sendDiscoveryRequest ( ) { try { if ( requests . isEmpty ( ) ) { // Do nothing if no request has been set return ; } for ( DiscoveryRequest req : requests ) { if ( req . getServiceTypes ( ) == null || req . getServiceTypes ( ) . isEmpty ( ) ) { clientSocket . send ( SsdpDiscovery . getDatagram ( null ) ) ; } else { for ( String st : req . getServiceTypes ( ) ) { clientSocket . send ( SsdpDiscovery . getDatagram ( st ) ) ; } } } } catch ( IOException e ) { if ( clientSocket . isClosed ( ) && ! State . ACTIVE . equals ( state ) ) { // This could happen when closing socket. In that case, this is not an issue. return ; } callback . onFailed ( e ) ; } }
Send discovery Multicast request .