CharGenUDPClient
, DaytimeUDPClient
, DiscardUDPClient
, TFTP
, TimeUDPClient
public abstract class DatagramSocketClient
extends java.lang.Object
DatagramSocketFactory
Modifier and Type | Field | Description |
---|---|---|
protected boolean |
_isOpen_ |
A status variable indicating if the client's socket is currently open.
|
protected java.net.DatagramSocket |
_socket_ |
The datagram socket used for the connection.
|
protected DatagramSocketFactory |
_socketFactory_ |
The datagram socket's DatagramSocketFactory.
|
protected int |
_timeout_ |
The timeout to use after opening a socket.
|
Constructor | Description |
---|---|
DatagramSocketClient() |
Default constructor for DatagramSocketClient.
|
Modifier and Type | Method | Description |
---|---|---|
void |
close() |
Closes the DatagramSocket used for the connection.
|
int |
getDefaultTimeout() |
Returns the default timeout in milliseconds that is used when
opening a socket.
|
java.net.InetAddress |
getLocalAddress() |
Returns the local address to which the client's socket is bound.
|
int |
getLocalPort() |
Returns the port number of the open socket on the local host used
for the connection.
|
int |
getSoTimeout() |
Returns the timeout in milliseconds of the currently opened socket.
|
boolean |
isOpen() |
Returns true if the client has a currently open socket.
|
void |
open() |
Opens a DatagramSocket on the local host at the first available port.
|
void |
open(int port) |
Opens a DatagramSocket on the local host at a specified port.
|
void |
open(int port,
java.net.InetAddress laddr) |
Opens a DatagramSocket at the specified address on the local host
at a specified port.
|
void |
setDatagramSocketFactory(DatagramSocketFactory factory) |
Sets the DatagramSocketFactory used by the DatagramSocketClient
to open DatagramSockets.
|
void |
setDefaultTimeout(int timeout) |
Set the default timeout in milliseconds to use when opening a socket.
|
void |
setSoTimeout(int timeout) |
Set the timeout in milliseconds of a currently open connection.
|
protected int _timeout_
protected java.net.DatagramSocket _socket_
protected boolean _isOpen_
protected DatagramSocketFactory _socketFactory_
public DatagramSocketClient()
public void open() throws java.net.SocketException
_isOpen_ is set to true after calling this method and _socket_ is set to the newly opened socket.
java.net.SocketException
- If the socket could not be opened or the
timeout could not be set.public void open(int port) throws java.net.SocketException
_isOpen_ is set to true after calling this method and _socket_ is set to the newly opened socket.
port
- The port to use for the socket.java.net.SocketException
- If the socket could not be opened or the
timeout could not be set.public void open(int port, java.net.InetAddress laddr) throws java.net.SocketException
_isOpen_ is set to true after calling this method and _socket_ is set to the newly opened socket.
port
- The port to use for the socket.laddr
- The local address to use.java.net.SocketException
- If the socket could not be opened or the
timeout could not be set.public void close()
public boolean isOpen()
public void setDefaultTimeout(int timeout)
timeout
- The timeout in milliseconds to use for the datagram socket
connection.public int getDefaultTimeout()
public void setSoTimeout(int timeout) throws java.net.SocketException
timeout
- The timeout in milliseconds to use for the currently
open datagram socket connection.java.net.SocketException
public int getSoTimeout() throws java.net.SocketException
java.net.SocketException
public int getLocalPort()
public java.net.InetAddress getLocalAddress()
public void setDatagramSocketFactory(DatagramSocketFactory factory)
factory
- The new DatagramSocketFactory the DatagramSocketClient
should use.Copyright © 1997-2002 Daniel F. Savarese. All Rights Reserved.