tuwien.auto.eicl

Class Discoverer

Implemented Interfaces:
Runnable

public class Discoverer
extends java.lang.Object
implements Runnable

The Discoverer class handles EIBnet/IP search and description requests. To be able to accept search and description responses, this class maintains its own socket and runs as an independent thread. This is, however, not of concern for the client application since thread instantiation is done implicitly in the constructor.

See Also:
CEMI_Connection, tuwien.auto.eicl.Heartbeat

Constructor Summary

Discoverer()
Opens a new socket with a random port number and establishes the new instance as a receiver thread.
Discoverer(int _LocalPort)
Opens a socket on the given port and establishes the new instance as a receiver thread.

Method Summary

Description_Response
getDescription(InetSocketAddress _SocketAddress, int _Timeout)
Sends a description request message and blocks until either the answer has been received or the timeout is reached.
InetSocketAddress[]
getSearchResponses()
Returns the socket addresses of the hosts that have answered the search request.
void
run()
The run method is responsible for receiving search and description messages.
void
sendSearchRequest()
Sends a search request message (multicast).

Constructor Details

Discoverer

public Discoverer()
Opens a new socket with a random port number and establishes the new instance as a receiver thread. If something goes wrong an Exception is thrown.

Discoverer

public Discoverer(int _LocalPort)
            throws EICLException
Opens a socket on the given port and establishes the new instance as a receiver thread.
Parameters:
_LocalPort - the socket port
Throws:
EICLException -

Method Details

getDescription

public Description_Response getDescription(InetSocketAddress _SocketAddress,
                                           int _Timeout)
            throws EICLException
Sends a description request message and blocks until either the answer has been received or the timeout is reached. If the timeout is reached an Exception is thrown.
Parameters:
_SocketAddress - The server socket address
_Timeout - Timeout (in seconds)
Returns:
The description response message
Throws:
EICLException - If the timeout was reached or something went wrong

getSearchResponses

public InetSocketAddress[] getSearchResponses()
Returns the socket addresses of the hosts that have answered the search request. You can invoke this method multiple times to check for new responses, only a new search request will erase the list of responses.
Returns:
fount hosts

run

public void run()
The run method is responsible for receiving search and description messages. It therefore blocks on the socket until a message arrives. It's not necessary to call it on your own; this is done by the constructor.

sendSearchRequest

public void sendSearchRequest()
            throws EICLException
Sends a search request message (multicast). The results can be accessed with the getSearchResponses() method. Note that a new search request causes getSearchResponses to forget previously received responses.
Throws:
EICLException -