|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectewe.net.DatagramSocket
A DatagramSocket is used for sending/receiving datagram (connectionless) IP packets (UDP).
| Field Summary | |
protected Object |
localHost
|
protected int |
localPortNotUsed
|
| Fields inherited from interface ewe.io.StreamCanPause |
PAUSE_UNTIL_CAN_READ, PAUSE_UNTIL_CAN_WRITE, PAUSE_UNTIL_CLOSED, PAUSE_UNTIL_FLUSHED |
| Constructor Summary | |
DatagramSocket()
Create a DatagramSocket bound to all addresses for the local host and to the next available port number. |
|
DatagramSocket(int port)
Create a DatagramSocket bound to all addresses for the local host and to the specified port number. |
|
DatagramSocket(int port,
InetAddress addr)
Create a DatagramSocket bound to a specific local host address and to a specified port number. |
|
DatagramSocket(int port,
String hostName)
This is generally only used to connect to the infra-red port, in which case you should set hostName to InetAddress.INFRA_RED. |
|
| Method Summary | |
void |
close()
|
InetAddress |
getLocalAddress()
Get the local address the DatagramSocket is bound to. |
int |
getLocalPort()
Return the port number on the local host to which this socket is bound. |
int |
getReceiveBufferSize()
|
int |
getSendBufferSize()
|
int |
pauseUntilReady(int type,
int time)
Do not call this directly, it is used internally. |
void |
receive(DatagramPacket packet)
Receive an incoming DatagramPacket. |
boolean |
receivePacket(DatagramPacket packet)
This is a non-blocking receive. |
void |
send(DatagramPacket packet)
Send a DatagramPacket This method will block until the data is sent. |
boolean |
sendPacket(DatagramPacket packet)
This is a non-blocking send. |
void |
setReceiveBufferSize(int size)
|
void |
setSendBufferSize(int size)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, toString |
| Field Detail |
protected Object localHost
protected int localPortNotUsed
| Constructor Detail |
public DatagramSocket()
throws SocketException
SocketException - if the DatagramSocket could not be created.
public DatagramSocket(int port)
throws SocketException
port - The port number to bind to. A port number of 0 requests the next available port.
SocketException - if the DatagramSocket could not be created.
public DatagramSocket(int port,
InetAddress addr)
throws SocketException
port - The port number to bind to. A port number of 0 requests the next available port.addr - An InetAddress representing one of the addresses assigned to the local host. If
this is null then the socket will be bound to all addresses.
SocketException - if the DatagramSocket could not be created.
public DatagramSocket(int port,
String hostName)
throws SocketException
port - The port number to bind to. A port number of 0 requests the next available port.hostName - The local host address (in dotted notation or InetAddress.INFRA_RED) to bind to.
SocketException - if the DatagramSocket could not be created.| Method Detail |
public int getLocalPort()
public void close()
public InetAddress getLocalAddress()
public int pauseUntilReady(int type,
int time)
pauseUntilReady in interface StreamCanPause
public boolean receivePacket(DatagramPacket packet)
throws IOException
packet - The destination to place the data in.
IOException - if an error occured receiving data.
public boolean sendPacket(DatagramPacket packet)
throws IOException
packet - The data to send.
IOException - if an error occured sending data.
public void receive(DatagramPacket packet)
throws IOException
packet - This is used to hold the incoming data.
IOException - if an error occurs while receiving data.
public void send(DatagramPacket packet)
throws IOException
packet - This is used to hold the outgoing data.
IOException - if an error occurs while sending the data.
public int getReceiveBufferSize()
throws SocketException
SocketException
public int getSendBufferSize()
throws SocketException
SocketException
public void setReceiveBufferSize(int size)
throws SocketException
SocketException
public void setSendBufferSize(int size)
throws SocketException
SocketException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||