java.lang.Object
org.cybergarage.upnp.ssdp.HTTPMUSocket
- Direct Known Subclasses:
SSDPNotifySocket, SSDPSearchSocket
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 Summary
FieldsModifier and TypeFieldDescriptionprivate InetAddressI2Pprivate InetSocketAddress/////////////////////////////////////////////private NetworkInterfaceInterface the multicast socket is bound to.private MulticastSocketThe multicast socket used for SSDP.Constructor Summary
ConstructorsConstructorDescription/////////////////////////////////////////////HTTPMUSocket(String addr, int port, String bindAddr) Create a new HTTPMU socket and open it.Method Summary
Public MethodsModifier and TypeMethodDescriptionbooleanclose()Close the multicast socket and leave the group.protected voidfinalize()Get the local address.intGet the source port for multicast packet.Get the multicast address string.Get the multicast inet address.intGet the destination port for multicast packet.Get the opened multicast socket.booleanOpen a multicast socket with the given string address.booleanopen(String addr, int port, InetAddress bindAddr) Open a multicast socket and join the given group.booleanpost(HTTPRequest req) Post an HTTP request using default bind settings.booleanpost(HTTPRequest req, String bindAddr, int bindPort) Post an HTTP request as a multicast message.receive()Receive a multicast packet.booleanSend a multicast message using default bind settings.booleanSend a multicast message.toString()I2P
Field Details
ssdpMultiGroup
/////////////////////////////////////////////ssdpMultiSock
The multicast socket used for SSDP.ssdpMultiIf
Interface the multicast socket is bound to._bindAddress
I2P
Constructor Details
HTTPMUSocket
public HTTPMUSocket()/////////////////////////////////////////////HTTPMUSocket
Method Details
finalize
protected void finalize()getLocalAddress
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
getMulticastInetAddress
Get the multicast inet address.- Returns:
- the multicast address
getMulticastAddress
open
Open a multicast socket and join the given group.- Parameters:
addr-Stringrappresenting the multicast hostname to join into.port- int rappresenting the port to be use poth as source and destinationbindAddr-InetAddresswhich identify the hostname of the interface to use for sending and receiving multicast packet- Returns:
- true if successful
open
close
public boolean close()Close the multicast socket and leave the group.- Returns:
- true if successful
send
send
Send a multicast message using default bind settings.- Parameters:
msg- the message to send- Returns:
- true if successful
post
Post an HTTP request as a multicast message.- Parameters:
req- the HTTP requestbindAddr- the bind addressbindPort- the bind port- Returns:
- true if successful
post
Post an HTTP request using default bind settings.- Parameters:
req- the HTTP request- Returns:
- true if successful
receive
Receive a multicast packet.- Returns:
- the received packet
- Throws:
IOException- if an I/O error occurs
toString