java.lang.Object
org.cybergarage.upnp.ssdp.HTTPMUSocket
Direct Known Subclasses:
SSDPNotifySocket, SSDPSearchSocket

public class HTTPMUSocketextends Object
Multicast UDP socket implementation for SSDP communication.

This class provides multicast socket functionality specifically designed for SSDP operations in UPnP networks. It handles both sending and receiving multicast UDP packets for device discovery and advertisement.

Key features:

  • Multicast socket management and configuration
  • SSDP multicast address handling
  • TTL (Time To Live) configuration
  • Network interface binding
  • Packet sending and receiving

This class is used by SSDP components to send multicast discovery messages and receive multicast advertisements from UPnP devices, enabling the core device discovery functionality in UPnP networks.

  • Field Details

    • ssdpMultiGroup

      private InetSocketAddress ssdpMultiGroup
      /////////////////////////////////////////////
    • ssdpMultiSock

      private MulticastSocket ssdpMultiSock
      The multicast socket used for SSDP.
    • ssdpMultiIf

      private NetworkInterface ssdpMultiIf
      Interface the multicast socket is bound to.
    • _bindAddress

      private InetAddress _bindAddress
      I2P
  • Constructor Details

    • HTTPMUSocket

      public HTTPMUSocket()
      /////////////////////////////////////////////
    • HTTPMUSocket

      public HTTPMUSocket(String addr, int port, String bindAddr)
      Create a new HTTPMU socket and open it.
      Parameters:
      addr - the multicast address
      port - the multicast port
      bindAddr - the bind address
  • Method Details

    • finalize

      protected void finalize()
    • getLocalAddress

      public String getLocalAddress()
      Get the local address.
      Returns:
      the local address string
    • getMulticastPort

      public int getMulticastPort()
      Get the destination port for multicast packet.
      Returns:
      the multicast port
    • getLocalPort

      public int getLocalPort()
      Get the source port for multicast packet.
      Returns:
      the local port
    • getSocket

      public MulticastSocket getSocket()
      Get the opened multicast socket.
      Returns:
      the MulticastSocket
    • getMulticastInetAddress

      public InetAddress getMulticastInetAddress()
      Get the multicast inet address.
      Returns:
      the multicast address
    • getMulticastAddress

      public String getMulticastAddress()
      Get the multicast address string.
      Returns:
      the multicast address
    • open

      public boolean open(String addr, int port, InetAddress bindAddr)
      Open a multicast socket and join the given group.
      Parameters:
      addr - String rappresenting the multicast hostname to join into.
      port - int rappresenting the port to be use poth as source and destination
      bindAddr - InetAddress which identify the hostname of the interface to use for sending and receiving multicast packet
      Returns:
      true if successful
    • open

      public boolean open(String addr, int port, String bindAddr)
      Open a multicast socket with the given string address.
      Parameters:
      addr - the multicast address
      port - the multicast port to join
      bindAddr - the bind address string
      Returns:
      true if successful
    • close

      public boolean close()
      Close the multicast socket and leave the group.
      Returns:
      true if successful
    • send

      public boolean send(String msg, String bindAddr, int bindPort)
      Send a multicast message.
      Parameters:
      msg - the message to send
      bindAddr - the bind address
      bindPort - the bind port
      Returns:
      true if successful
    • send

      public boolean send(String msg)
      Send a multicast message using default bind settings.
      Parameters:
      msg - the message to send
      Returns:
      true if successful
    • post

      public boolean post(HTTPRequest req, String bindAddr, int bindPort)
      Post an HTTP request as a multicast message.
      Parameters:
      req - the HTTP request
      bindAddr - the bind address
      bindPort - the bind port
      Returns:
      true if successful
    • post

      public boolean post(HTTPRequest req)
      Post an HTTP request using default bind settings.
      Parameters:
      req - the HTTP request
      Returns:
      true if successful
    • receive

      public SSDPPacket receive() throws IOException
      Receive a multicast packet.
      Returns:
      the received packet
      Throws:
      IOException - if an I/O error occurs
    • toString

      public String toString()
      I2P
      Overrides:
      toString in class Object