java.lang.Object
org.cybergarage.upnp.ssdp.HTTPUSocket
org.cybergarage.upnp.ssdp.SSDPSearchResponseSocket
- All Implemented Interfaces:
Runnable
Socket for receiving SSDP search responses from UPnP devices.
This class extends HTTPUSocket and implements Runnable to provide asynchronous handling of SSDP search responses. It listens for responses to M-SEARCH messages sent during device discovery operations.
Key features:
- Asynchronous response reception
- SSDP search response parsing
- Multi-threaded operation
- Network interface binding
- Control point notification
This class is used by UPnP control points to receive responses from devices when performing device discovery searches. It runs in a separate thread to continuously listen for incoming search responses without blocking the main application.
Constructor Summary
ConstructorsConstructorDescriptionBind a search response socket to the default address and port.SSDPSearchResponseSocket(String bindAddr, int port) Bind a search response socket to the given address and port.Method Summary
All MethodsModifier and TypeMethodDescriptionThe control point this socket reports search results to.booleanpost(String addr, int port, SSDPSearchRequest req) Send a search request to the given address.booleanpost(String addr, int port, SSDPSearchResponse res) Send a search response back to the requester.voidrun()Watch for inbound search requests and answer them.voidsetControlPoint(ControlPoint ctrlp) Attach the control point this socket reports search results to.voidstart()Start the response thread.voidstop()Stop the response thread.Methods inherited from class HTTPUSocket
close, finalize, getDatagramSocket, getLocalAddress, getUDPSocket, open, open, open, post, receive, setLocalAddress, toStringModifier and TypeMethodDescriptionbooleanclose()Close the socket and clear the reference to it.protected voidfinalize()Close the socket when the object is garbage collected.Open a datagram socket on an ephemeral port, for SSDP unicast traffic.Return the local address this socket reports.Return the underlying datagram socket, for callers that need it directly.booleanopen()Open a datagram socket on an ephemeral port, replacing any open socket.booleanopen(int bindPort) Open a datagram socket bound to a local port with address reuse allowed.booleanOpen a datagram socket bound to a local address and port.booleanSend one SSDP message as a UDP datagram.receive()Block until one datagram arrives, then wrap it as an SSDP packet.voidsetLocalAddress(String addr) Override the address this socket reports as its own.toString()Return the local address this socket reports.
Constructor Details
SSDPSearchResponseSocket
public SSDPSearchResponseSocket()Bind a search response socket to the default address and port.SSDPSearchResponseSocket
Bind a search response socket to the given address and port.- Parameters:
bindAddr- the address to bind toport- the port to bind to
Method Details
setControlPoint
Attach the control point this socket reports search results to.- Parameters:
ctrlp- the control point, may be null
getControlPoint
The control point this socket reports search results to.- Returns:
- the control point, null when none is attached
run
start
public void start()Start the response thread.stop
public void stop()Stop the response thread.post
Send a search response back to the requester.- Parameters:
addr- the address to send toport- the port to send tores- the response to send- Returns:
- true if the datagram was sent
post
Send a search request to the given address.- Parameters:
addr- the address to send toport- the port to send toreq- the request to send- Returns:
- true if the datagram was sent