seda.nbio.NonblockingDatagramSocket Class Reference

Inherits DatagramSocket, and seda.nbio.Selectable.

Inherited by seda.nbio.NonblockingMulticastSocket.

List of all members.


Detailed Description

A NonblockingDatagramSocket provides non-blocking UDP (datagram) I/O.


Public Member Functions

 NonblockingDatagramSocket () throws IOException
 Create a NonblockingDatagramSocket bound to any available port.
 NonblockingDatagramSocket (int port) throws IOException
 Create a NonblockingDatagramSocket bound to the given port.
 NonblockingDatagramSocket (int port, InetAddress laddr) throws IOException
 Create a NonblockingDatagramSocket bound to the given port and the given local address.
synchronized void close ()
 Close this NonblockingDatagramSocket.
void connect (InetAddress address, int port) throws IllegalArgumentException
 Connect this NonblockingDatagramSocket to the given address and port.
void connect (String host, int port) throws UnknownHostException
synchronized void disconnect ()
InetAddress getInetAddress ()
 Return the remote address to which this socket is bound.
InetAddress getLocalAddress ()
 Return the local address to which this socket is bound.
int getPort ()
 Return the remote port to which this socket is bound.
int getLocalPort ()
 Return the local port to which this socket is bound.
int nbReceive (DatagramPacket p) throws IOException
 Receive a datagram from this socket.
int nbReceive (byte[] data, int offset, int length) throws IOException
 Receive a datagram from this socket.
int nbSend (DatagramPacket p) throws IOException
 Sends a datagram packet from this socket.
int nbSend (byte[] data, int offset, int length, InetAddress addr, int port) throws IOException
 Sends a datagram packet from this socket.
int nbSend (byte[] data, int offset, int length) throws IOException
 Sends a datagram packet from this socket.
int getReceiveBufferSize () throws SocketException
int getSendBufferSize () throws SocketException
void setReceiveBufferSize (int size) throws SocketException
void setSendBufferSize (int size) throws SocketException
void send (DatagramPacket p) throws IOException
 This method is provided for convenience and mimics blocking behavior by invoking the nonblocking nbSend() operation.
void receive (DatagramPacket p) throws IOException
 This method is provided for convenience and mimics blocking behavior by invoking the nonblocking nbReceive() operation.

Static Package Functions

 [static initializer]

Package Attributes

NonblockingSocketImpl impl
boolean is_connected


Constructor & Destructor Documentation

seda.nbio.NonblockingDatagramSocket.NonblockingDatagramSocket (  )  throws IOException

Create a NonblockingDatagramSocket bound to any available port.

seda.nbio.NonblockingDatagramSocket.NonblockingDatagramSocket ( int  port  )  throws IOException

Create a NonblockingDatagramSocket bound to the given port.

seda.nbio.NonblockingDatagramSocket.NonblockingDatagramSocket ( int  port,
InetAddress  laddr 
) throws IOException

Create a NonblockingDatagramSocket bound to the given port and the given local address.


Member Function Documentation

seda.nbio.NonblockingDatagramSocket.[static initializer] (  )  [static, package]

synchronized void seda.nbio.NonblockingDatagramSocket.close (  ) 

Close this NonblockingDatagramSocket.

void seda.nbio.NonblockingDatagramSocket.connect ( String  host,
int  port 
) throws UnknownHostException

void seda.nbio.NonblockingDatagramSocket.connect ( InetAddress  address,
int  port 
) throws IllegalArgumentException

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.

synchronized void seda.nbio.NonblockingDatagramSocket.disconnect (  ) 

InetAddress seda.nbio.NonblockingDatagramSocket.getInetAddress (  ) 

Return the remote address to which this socket is bound.

Should be null if the socket hasn't been connected to anything.

InetAddress seda.nbio.NonblockingDatagramSocket.getLocalAddress (  ) 

Return the local address to which this socket is bound.

int seda.nbio.NonblockingDatagramSocket.getLocalPort (  ) 

Return the local port to which this socket is bound.

int seda.nbio.NonblockingDatagramSocket.getPort (  ) 

Return the remote port to which this socket is bound.

int seda.nbio.NonblockingDatagramSocket.getReceiveBufferSize (  )  throws SocketException

int seda.nbio.NonblockingDatagramSocket.getSendBufferSize (  )  throws SocketException

int seda.nbio.NonblockingDatagramSocket.nbReceive ( byte[]  data,
int  offset,
int  length 
) throws IOException

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.

Returns:
The size of the received packet, or 0 if no data was received.

int seda.nbio.NonblockingDatagramSocket.nbReceive ( DatagramPacket  p  )  throws IOException

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.

Returns:
The size of the received packet, or 0 if no data was received.

int seda.nbio.NonblockingDatagramSocket.nbSend ( byte[]  data,
int  offset,
int  length 
) throws IOException

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.

Returns:
The amount of data sent, or 0 if the packet could not be sent immediately.

int seda.nbio.NonblockingDatagramSocket.nbSend ( byte[]  data,
int  offset,
int  length,
InetAddress  addr,
int  port 
) throws IOException

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.

Returns:
The amount of data sent, or 0 if the packet could not be sent immediately.

int seda.nbio.NonblockingDatagramSocket.nbSend ( DatagramPacket  p  )  throws IOException

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.

Returns:
The amount of data sent, or 0 if the packet could not be sent immediately.

void seda.nbio.NonblockingDatagramSocket.receive ( DatagramPacket  p  )  throws IOException

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.

void seda.nbio.NonblockingDatagramSocket.send ( DatagramPacket  p  )  throws IOException

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.

void seda.nbio.NonblockingDatagramSocket.setReceiveBufferSize ( int  size  )  throws SocketException

void seda.nbio.NonblockingDatagramSocket.setSendBufferSize ( int  size  )  throws SocketException


Member Data Documentation

NonblockingSocketImpl seda.nbio.NonblockingDatagramSocket.impl [package]

boolean seda.nbio.NonblockingDatagramSocket.is_connected [package]


The documentation for this class was generated from the following file:
Generated on Mon Oct 30 12:28:00 2006 for libnbio2-java by  doxygen 1.4.7