Methods Summary |
---|
public void | close()Closes the DatagramSocket used for the connection.
You should call this method after you've finished using the class
instance and also before you call {@link #open open() }
again. _isOpen_ is set to false and _socket_ is set to null.
If you call this method when the client socket is not open,
a NullPointerException is thrown.
_socket_.close();
_socket_ = null;
_isOpen_ = false;
|
public int | getDefaultTimeout()Returns the default timeout in milliseconds that is used when
opening a socket.
return _timeout_;
|
public java.net.InetAddress | getLocalAddress()Returns the local address to which the client's socket is bound.
If you call this method when the client socket is not open, a
NullPointerException is thrown.
return _socket_.getLocalAddress();
|
public int | getLocalPort()Returns the port number of the open socket on the local host used
for the connection. If you call this method when the client socket
is not open, a NullPointerException is thrown.
return _socket_.getLocalPort();
|
public int | getSoTimeout()Returns the timeout in milliseconds of the currently opened socket.
If you call this method when the client socket is not open,
a NullPointerException is thrown.
return _socket_.getSoTimeout();
|
public boolean | isOpen()Returns true if the client has a currently open socket.
return _isOpen_;
|
public void | open()Opens a DatagramSocket on the local host at the first available port.
Also sets the timeout on the socket to the default timeout set
by {@link #setDefaultTimeout setDefaultTimeout() }.
_isOpen_ is set to true after calling this method and _socket_
is set to the newly opened socket.
_socket_ = _socketFactory_.createDatagramSocket();
_socket_.setSoTimeout(_timeout_);
_isOpen_ = true;
|
public void | open(int port)Opens a DatagramSocket on the local host at a specified port.
Also sets the timeout on the socket to the default timeout set
by {@link #setDefaultTimeout setDefaultTimeout() }.
_isOpen_ is set to true after calling this method and _socket_
is set to the newly opened socket.
_socket_ = _socketFactory_.createDatagramSocket(port);
_socket_.setSoTimeout(_timeout_);
_isOpen_ = true;
|
public void | open(int port, java.net.InetAddress laddr)Opens a DatagramSocket at the specified address on the local host
at a specified port.
Also sets the timeout on the socket to the default timeout set
by {@link #setDefaultTimeout setDefaultTimeout() }.
_isOpen_ is set to true after calling this method and _socket_
is set to the newly opened socket.
_socket_ = _socketFactory_.createDatagramSocket(port, laddr);
_socket_.setSoTimeout(_timeout_);
_isOpen_ = true;
|
public void | setDatagramSocketFactory(DatagramSocketFactory factory)Sets the DatagramSocketFactory used by the DatagramSocketClient
to open DatagramSockets. If the factory value is null, then a default
factory is used (only do this to reset the factory after having
previously altered it).
if (factory == null)
_socketFactory_ = __DEFAULT_SOCKET_FACTORY;
else
_socketFactory_ = factory;
|
public void | setDefaultTimeout(int timeout)Set the default timeout in milliseconds to use when opening a socket.
After a call to open, the timeout for the socket is set using this value.
This method should be used prior to a call to {@link #open open()}
and should not be confused with {@link #setSoTimeout setSoTimeout()}
which operates on the currently open socket. _timeout_ contains
the new timeout value.
_timeout_ = timeout;
|
public void | setSoTimeout(int timeout)Set the timeout in milliseconds of a currently open connection.
Only call this method after a connection has been opened
by {@link #open open()}.
_socket_.setSoTimeout(timeout);
|