| java.lang.Object java.net.DatagramSocket seda.nbio.NonblockingDatagramSocket
All known Subclasses: seda.nbio.NonblockingMulticastSocket,
NonblockingDatagramSocket | public class NonblockingDatagramSocket extends DatagramSocket implements Selectable(Code) | | A NonblockingDatagramSocket provides non-blocking UDP (datagram) I/O.
|
Method Summary | |
public synchronized void | close() Close this NonblockingDatagramSocket. | public void | connect(InetAddress address, int port) Connect this NonblockingDatagramSocket to the given address and port. | public void | connect(String host, int port) | public synchronized void | disconnect() | public InetAddress | getInetAddress() Return the remote address to which this socket is bound. | public InetAddress | getLocalAddress() Return the local address to which this socket is bound. | public int | getLocalPort() Return the local port to which this socket is bound. | public int | getPort() Return the remote port to which this socket is bound. | public int | getReceiveBufferSize() | public int | getSendBufferSize() | public int | nbReceive(DatagramPacket p) Receive a datagram from this socket. | public int | nbReceive(byte[] data, int offset, int length) Receive a datagram from this socket. | public int | nbSend(DatagramPacket p) Sends a datagram packet from this socket. | public int | nbSend(byte[] data, int offset, int length, InetAddress addr, int port) Sends a datagram packet from this socket. | public int | nbSend(byte[] data, int offset, int length) Sends a datagram packet from this socket. | public void | receive(DatagramPacket p) This method is provided for convenience and mimics blocking behavior
by invoking the nonblocking nbReceive() operation. | public void | send(DatagramPacket p) This method is provided for convenience and mimics blocking behavior
by invoking the nonblocking nbSend() operation. | public void | setReceiveBufferSize(int size) | public void | setSendBufferSize(int size) |
is_connected | boolean is_connected(Code) | | |
NonblockingDatagramSocket | public NonblockingDatagramSocket() throws IOException(Code) | | Create a NonblockingDatagramSocket bound to any available port.
|
NonblockingDatagramSocket | public NonblockingDatagramSocket(int port) throws IOException(Code) | | Create a NonblockingDatagramSocket bound to the given port.
|
NonblockingDatagramSocket | public NonblockingDatagramSocket(int port, InetAddress laddr) throws IOException(Code) | | Create a NonblockingDatagramSocket bound to the given port and
the given local address.
|
close | public synchronized void close()(Code) | | Close this NonblockingDatagramSocket.
|
connect | public void connect(InetAddress address, int port) throws IllegalArgumentException(Code) | | Connect this NonblockingDatagramSocket to the given address and port.
All send() operations with a NULL 'sendTo' address will now send
to this address by default. You may call connect() multiple times
on a NonblockingDatagramSocket to change the default send address.
|
disconnect | public synchronized void disconnect()(Code) | | |
getInetAddress | public InetAddress getInetAddress()(Code) | | Return the remote address to which this socket is bound.
Should be null if the socket hasn't been connected
to anything.
|
getLocalAddress | public InetAddress getLocalAddress()(Code) | | Return the local address to which this socket is bound.
|
getLocalPort | public int getLocalPort()(Code) | | Return the local port to which this socket is bound.
|
getPort | public int getPort()(Code) | | Return the remote port to which this socket is bound.
|
nbReceive | public int nbReceive(DatagramPacket p) throws IOException(Code) | | Receive a datagram from this socket. When this method returns, the
DatagramPacket's buffer is filled with the data received. The datagram
packet also contains the sender's IP address, and the port number
on the sender's machine.
This method does not block if a datagram is not ready to be received.
The length field of the datagram packet object contains the length
of the received message, or is set to 0 if no packet was received.
If the message is longer than the packet's length, the message is
truncated.
The size of the received packet, or 0 if no data was received. |
nbReceive | public int nbReceive(byte[] data, int offset, int length) throws IOException(Code) | | Receive a datagram from this socket. When this method returns, the
given byte array is filled with the data received starting at the given
offset with the given length. If the message is longer than the given
length, the message is truncated.
This method does not block if a datagram is not ready to be received.
The size of the received packet, or 0 if no data was received. |
nbSend | public int nbSend(DatagramPacket p) throws IOException(Code) | | Sends a datagram packet from this socket. The DatagramPacket includes
information indicating the data to be sent, its length, the IP
address of the remote host, and the port number on the remote host.
This method does not block; it returns 0 if the packet could not
be sent.
The amount of data sent, or 0 if the packet could not be sentimmediately. |
nbSend | public int nbSend(byte[] data, int offset, int length, InetAddress addr, int port) throws IOException(Code) | | Sends a datagram packet from this socket. This method constructs
a temporary DatagramPacket from the given data, offset, length,
address, and port, and calls nbSend(DatagramPacket p).
This method does not block; it returns 0 if the packet could not
be sent.
The amount of data sent, or 0 if the packet could not be sentimmediately. |
nbSend | public int nbSend(byte[] data, int offset, int length) throws IOException(Code) | | Sends a datagram packet from this socket. This method constructs
a temporary DatagramPacket from the given data, offset, and length.
This method may only be called on a connected socket; if called
on an unconnected socket, an IllegalArgumentException is thrown.
This method does not block; it returns 0 if the packet could not
be sent.
The amount of data sent, or 0 if the packet could not be sentimmediately. |
receive | public void receive(DatagramPacket p) throws IOException(Code) | | This method is provided for convenience and mimics blocking behavior
by invoking the nonblocking nbReceive() operation. If no packet could
be immediately received it returns immediately with a received packet
length of 0.
Use of this method is not recommended and is provided only
for compatibility with java.net.DatagramSocket.
|
send | public void send(DatagramPacket p) throws IOException(Code) | | This method is provided for convenience and mimics blocking behavior
by invoking the nonblocking nbSend() operation. If the packet could
not be immediately sent it is simply dropped (because this is a UDP
socket this behavior is consistent with the lack of reliability in UDP).
Use of this method is not recommended and is provided only
for compatibility with java.net.DatagramSocket.
|
|
|