public class DatagramSocket extends Object
Constructor and Description |
---|
DatagramSocket() |
DatagramSocket(int port) |
DatagramSocket(int port,
InetAddress laddr) |
DatagramSocket(SocketAddress saddr) |
Modifier and Type | Method and Description |
---|---|
void |
bind(SocketAddress bindAddr) |
void |
close()
closes this socket.
|
void |
connect(InetAddress address,
int port)
* Connects the datagramsocket to a remote address.
|
void |
connect(SocketAddress sa)
* Connects the datagramsocket to a remote address.
|
void |
disconnect()
Disconnects the socket.
|
boolean |
getBroadcast() |
InetAddress |
getInetAddress()
The address to which this socket is connected or null if not connected.
|
InetAddress |
getLocalAddress()
* gets the local address to which the socket is bound.
|
int |
getLocalPort()
The port number on the local host to which this socket is bound.
|
SocketAddress |
getLocalSocketAddress()
The local address to which this socket is bound or null if not bound.
|
int |
getPort()
The port off the socket t o which this socket is connected or -1 if this socket is not connected.
|
int |
getReceiveBufferSize()
returns the size of the 'recieve' buffers of this socket.
|
SocketAddress |
getRemoteSocketAddress()
The remote address to which this socket is connected or null if not connected.
|
boolean |
getReuseAddress() |
int |
getSendBufferSize()
returns the size of the 'send' buffers of this socket.
|
int |
getSoTimeout()
returns the timeout value of this socket.
|
int |
getTrafficCless() |
boolean |
isBound() |
boolean |
isClosed() |
boolean |
isConnected() |
void |
receive(DatagramPacket p)
Receives a datagram packet from this socket.
|
void |
send(DatagramPacket p)
Sends a datagram packet from this socket.
|
void |
setBroadcast(boolean on) |
static void |
setDatagramSocketImplFactory(DatagramSocketImplFactory factory) |
void |
setReceiveBufferSize(int size)
This method tries to set the 'recieve' buffersize.
|
void |
setReuseAddress(boolean on) |
void |
setSendBufferSize(int size)
This method tries to set the 'send' buffersize.
|
void |
setSoTimeout(int timeout)
set the socket timeout values.
|
void |
setTrafficClass(int tc) |
public DatagramSocket(SocketAddress saddr) throws SocketException
SocketException
public DatagramSocket() throws SocketException, SecurityException
SocketException
SecurityException
public DatagramSocket(int port) throws SocketException, SecurityException
SocketException
SecurityException
public DatagramSocket(int port, InetAddress laddr) throws SocketException, SecurityException
SocketException
SecurityException
public static void setDatagramSocketImplFactory(DatagramSocketImplFactory factory) throws IOException
IOException
public void setReuseAddress(boolean on) throws SocketException
SocketException
public void setTrafficClass(int tc) throws SocketException
SocketException
public void bind(SocketAddress bindAddr) throws SocketException
SocketException
public void connect(InetAddress address, int port) throws SecurityException
SecurityException
public void connect(SocketAddress sa) throws SecurityException
SecurityException
public void disconnect()
public boolean getBroadcast() throws SocketException
SocketException
public void setBroadcast(boolean on) throws SocketException
SocketException
public InetAddress getInetAddress()
public SocketAddress getLocalSocketAddress()
public SocketAddress getRemoteSocketAddress()
public int getPort()
public void send(DatagramPacket p) throws IOException
IOException
public void receive(DatagramPacket p) throws IOException
IOException
public InetAddress getLocalAddress()
public int getLocalPort()
public void setSoTimeout(int timeout) throws SocketException
throws
- an IllegalArgumentException if timeout < 0SocketException
public int getSoTimeout() throws SocketException
SocketException
public int getTrafficCless()
public void setSendBufferSize(int size) throws SocketException
SocketException
public int getSendBufferSize() throws SocketException
SocketException
public void setReceiveBufferSize(int size) throws SocketException
SocketException
public int getReceiveBufferSize() throws SocketException
SocketException
public boolean getReuseAddress() throws SocketException
SocketException
public void close()
public boolean isBound()
public boolean isConnected()
public boolean isClosed()