|
DthingApi
|
Public Member Functions | |
| DatagramSocket () throws SocketException | |
| DatagramSocket (int aPort) throws SocketException | |
| DatagramSocket (int aPort, InetAddress addr) throws SocketException | |
| void | close () |
| void | disconnect () |
| InetAddress | getInetAddress () |
| InetAddress | getLocalAddress () |
| int | getLocalPort () |
| int | getPort () |
| synchronized int | getReceiveBufferSize () throws SocketException |
| synchronized int | getSendBufferSize () throws SocketException |
| synchronized int | getSoTimeout () throws SocketException |
| synchronized void | receive (DatagramPacket pack) throws IOException |
| void | send (DatagramPacket pack) throws IOException |
| synchronized void | setSendBufferSize (int size) throws SocketException |
| synchronized void | setReceiveBufferSize (int size) throws SocketException |
| synchronized void | setSoTimeout (int timeout) throws SocketException |
| DatagramSocket (SocketAddress localAddr) throws SocketException | |
| void | bind (SocketAddress localAddr) throws SocketException |
| void | connect (SocketAddress peer) throws SocketException |
| void | connect (InetAddress address, int port) |
| boolean | isBound () |
| boolean | isConnected () |
| SocketAddress | getRemoteSocketAddress () |
| SocketAddress | getLocalSocketAddress () |
| boolean | getReuseAddress () throws SocketException |
| boolean | getBroadcast () throws SocketException |
| void | setTrafficClass (int value) throws SocketException |
| int | getTrafficClass () throws SocketException |
| boolean | isClosed () |
Protected Member Functions | |
| DatagramSocket (DatagramSocketImpl socketImpl) | |
This class implements a UDP socket for sending and receiving
. A
object can be used for both endpoints of a connection for a packet delivery service.
|
inline |
Constructs a UDP datagram socket which is bound to any available port on the localhost.
| SocketException | if an error occurs while creating or binding the socket. |
|
inline |
Constructs a UDP datagram socket which is bound to the specific port
on the localhost. Valid values for
are between 0 and 65535 inclusive.
| aPort | the port to bind on the localhost. |
| SocketException | if an error occurs while creating or binding the socket. |
|
inline |
Constructs a UDP datagram socket which is bound to the specific local address
on port
. Valid values for
are between 0 and 65535 inclusive.
| aPort | the port to bind on the localhost. |
| addr | the address to bind on the localhost. |
| SocketException | if an error occurs while creating or binding the socket. |
|
inlineprotected |
Constructs a new
using the specific datagram socket implementation
. The created
will not be bound.
| socketImpl | the DatagramSocketImpl to use. |
|
inline |
Constructs a new
bound to the host/port specified by the
or an unbound
if the
is
.
| localAddr | the local machine address and port to bind to. |
| IllegalArgumentException | if the SocketAddress is not supported |
| SocketException | if a problem occurs creating or binding the socket. |
|
inline |
Binds this socket to the local address and port specified by
. If this value is
any free port on a valid local address is used.
| localAddr | the local machine address and port to bind on. |
| IllegalArgumentException | if the SocketAddress is not supported |
| SocketException | if the socket is already bound or a problem occurs during binding. |
|
inline |
Closes this UDP datagram socket and all possibly associated channels.
|
inline |
Connects this datagram socket to the address and port specified by
. Future calls to send will use this as the default target, and receive will only accept packets from this source.
| SocketException | if an error occurs. |
|
inline |
Connects this datagram socket to the specific
and
. Future calls to send will use this as the default target, and receive will only accept packets from this source.
Beware: because it can't throw, this method silently ignores failures. Use connect(SocketAddress) instead.
|
inline |
Disconnects this UDP datagram socket from the remote host. This method called on an unconnected socket does nothing.
|
inline |
Gets the state of the socket option
.
| SocketException | if the socket is closed or the option is invalid. |
|
inline |
Gets the
instance representing the remote address to which this UDP datagram socket is connected.
|
inline |
Gets the
instance representing the bound local address of this UDP datagram socket.
|
inline |
Gets the local port which this socket is bound to.
|
inline |
Returns the
this socket is bound to, or null for an unbound socket.
|
inline |
Gets the remote port which this socket is connected to.
|
inline |
Returns this socket's receive buffer size.
|
inline |
Returns the
this socket is connected to, or null for an unconnected socket.
|
inline |
Gets the state of the socket option
.
| SocketException | if the socket is closed or the option is invalid. |
|
inline |
Returns this socket's send buffer size.
|
inline |
Gets the socket receive timeout.
| SocketException | if an error occurs while getting the option value. |
|
inline |
Returns this socket's {
| SocketException | if the socket is closed or the option is invalid. |
|
inline |
Returns true if this socket is bound to a local address. See bind.
|
inline |
Gets the state of this socket.
|
inline |
Returns true if this datagram socket is connected to a remote address. See connect.
|
inline |
Receives a packet from this socket and stores it in the argument
. All fields of
must be set according to the data received. If the received data is longer than the packet buffer size it is truncated. This method blocks until a packet is received or a timeout has expired.
| pack | the DatagramPacket |
| IOException | if an error occurs while receiving the packet. |
|
inline |
Sends a packet over this socket.
| pack | the DatagramPacket |
| IOException | if an error occurs while sending the packet. |
|
inline |
Sets this socket's receive buffer size.
|
inline |
Sets this socket's send buffer size.
|
inline |
Sets the read timeout in milliseconds for this socket. This receive timeout defines the period the socket will block waiting to receive data before throwing an
. The value
(default) is used to set an infinite timeout. To have effect this option must be set before the blocking method was called.
| timeout | the timeout in milliseconds or 0 for no timeout. |
| SocketException | if an error occurs while setting the option. |
|
inline |
Sets the {
| SocketException | if the socket is closed or the option could not be set. |
1.8.13