java.lang.Object
org.cybergarage.upnp.ssdp.HTTPMUSocket
org.cybergarage.upnp.ssdp.SSDPSearchSocket
All Implemented Interfaces:
Runnable

public class SSDPSearchSocketextends HTTPMUSocket implements Runnable
Socket for sending SSDP search requests and receiving responses.

This class extends HTTPMUSocket and implements Runnable to provide asynchronous handling of SSDP search operations. It manages both sending M-SEARCH requests and receiving device responses.

Key features:

  • IPv4 and IPv6 support
  • Multicast search request broadcasting
  • Asynchronous response reception
  • Multi-threaded operation
  • Network interface binding

This class is used by UPnP control points to perform device discovery by sending M-SEARCH requests to the SSDP multicast address and receiving responses from available devices on the network.

  • Field Details

    • useIPv6Address

      private boolean useIPv6Address
      True when this socket binds an IPv6 address.
    • deviceSearchListenerList

      private ListenerList deviceSearchListenerList
      Listeners notified of each device search.
    • deviceSearchThread

      private Thread deviceSearchThread
      The thread listening for searches.
  • Constructor Details

    • SSDPSearchSocket

      public SSDPSearchSocket(String bindAddr, int port, String multicast) throws IOException
      Binds the search socket for SSDP multicast traffic.
      Parameters:
      bindAddr - The address to bind the service
      port - The port used for accepting message
      multicast - The multicast address to use as destination
      Throws:
      IOException - if the socket cannot be bound to bindAddr
    • SSDPSearchSocket

      public SSDPSearchSocket(InetAddress bindAddr) throws IOException
      Binds the search socket to an IPv4 or IPv6 local address.
      Parameters:
      bindAddr - the binding address for sending multicast packet
      Throws:
      IOException - if the socket cannot be bound to bindAddr
  • Method Details

    • open

      public boolean open(Inet4Address bindAddr)
      Opens the socket joined to the IPv4 SSDP multicast group.
      Parameters:
      bindAddr - the IPv4 local address to send multicast packets from
      Returns:
      true if and only if it open the socket
    • open

      public boolean open(Inet6Address bindAddr)
      Opens the socket joined to the IPv6 SSDP multicast group.
      Parameters:
      bindAddr - the IPv6 local address to send multicast packets from
      Returns:
      true if and only if it open the socket
    • open

      public boolean open(String bind, String multicast)
      Opens the socket on the given local address and multicast group.
      Parameters:
      bind - the local address or hostname to send multicast packets from
      multicast - the destination multicast address, which must be of the same IP version as bind
      Returns:
      true if and only if it open the socket
    • open

      public boolean open(String bindAddr)
      Opens the socket, picking the IP version from the bind hostname.
      Parameters:
      bindAddr - the hostname of the interface to use for sending multicast packet
      Returns:
      true if and only if it open the socket
      See Also:
    • addSearchListener

      public void addSearchListener(SearchListener listener)
      Registers a listener for incoming device searches.
      Parameters:
      listener - the listener notified for every received search request
    • removeSearchListener

      public void removeSearchListener(SearchListener listener)
      Unregisters a previously added search listener.
      Parameters:
      listener - the listener to stop notifying
    • performSearchListener

      public void performSearchListener(SSDPPacket ssdpPacket)
      Hands a received search request to every registered listener.
      Parameters:
      ssdpPacket - the received search request to hand to every registered listener
    • run

      public void run()
      Receives and dispatches search packets until the thread is replaced.
      Specified by:
      run in interface Runnable
    • start

      public void start()
      Launches the receive thread under a name naming the multicast group.
    • stop

      public void stop()
      Closes the socket and unhooks the receive thread.