Example usage for Java java.net DatagramSocket fields, constructors, methods, implement or subclass
The text is from its open source code.
DatagramSocket(DatagramSocketImpl impl) Creates an unbound datagram socket with the specified DatagramSocketImpl. | |
DatagramSocket(SocketAddress bindaddr) Creates a datagram socket, bound to the specified local socket address. | |
DatagramSocket(int port) Constructs a datagram socket and binds it to the specified port on the local host machine. | |
DatagramSocket() Constructs a datagram socket and binds it to any available port on the local host machine. | |
DatagramSocket(int port, InetAddress laddr) Creates a datagram socket, bound to the specified local address. |
void | bind(SocketAddress addr) Binds this DatagramSocket to a specific address and port. |
void | close() Closes this datagram socket. |
void | connect(SocketAddress addr) Connects this socket to a remote socket address (IP address + port number). |
void | connect(InetAddress address, int port) Connects the socket to a remote address for this socket. |
void | disconnect() Disconnects the socket. |
boolean | getBroadcast() Tests if SO_BROADCAST is enabled. |
DatagramChannel | getChannel() Returns the unique java.nio.channels.DatagramChannel object associated with this datagram socket, if any. |
InetAddress | getInetAddress() Returns the address to which this socket is connected. |
InetAddress | getLocalAddress() Gets the local address to which the socket is bound. |
int | getLocalPort() Returns the port number on the local host to which this socket is bound. |
SocketAddress | getLocalSocketAddress() Returns the address of the endpoint this socket is bound to. |
int | getPort() Returns the port number to which this socket is connected. |
int | getReceiveBufferSize() Get value of the SO_RCVBUF option for this DatagramSocket , that is the buffer size used by the platform for input on this DatagramSocket . |
SocketAddress | getRemoteSocketAddress() Returns the address of the endpoint this socket is connected to, or null if it is unconnected. |
boolean | getReuseAddress() Tests if SO_REUSEADDR is enabled. |
int | getSendBufferSize() Get value of the SO_SNDBUF option for this DatagramSocket , that is the buffer size used by the platform for output on this DatagramSocket . |
int | getSoTimeout() Retrieve setting for SO_TIMEOUT. |
int | getTrafficClass() Gets traffic class or type-of-service in the IP datagram header for packets sent from this DatagramSocket. |
boolean | isBound() Returns the binding state of the socket. |
boolean | isClosed() Returns whether the socket is closed or not. |
boolean | isConnected() Returns the connection state of the socket. |
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) Enable/disable SO_BROADCAST. |
void | setDatagramSocketImplFactory(DatagramSocketImplFactory fac) Sets the datagram socket implementation factory for the application. |
void | setReceiveBufferSize(int size) Sets the SO_RCVBUF option to the specified value for this DatagramSocket . |
void | setReuseAddress(boolean on) Enable/disable the SO_REUSEADDR socket option. |
void | setSendBufferSize(int size) Sets the SO_SNDBUF option to the specified value for this DatagramSocket . |
void | setSoTimeout(int timeout) Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds. |
void | setTrafficClass(int tc) Sets traffic class or type-of-service octet in the IP datagram header for datagrams sent from this DatagramSocket. |