Java java.net DatagramSocket fields, constructors, methods, implement or subclass

Example usage for Java java.net DatagramSocket fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for java.net DatagramSocket.

The text is from its open source code.

Constructor

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.

Method

voidbind(SocketAddress addr)
Binds this DatagramSocket to a specific address and port.
voidclose()
Closes this datagram socket.
voidconnect(SocketAddress addr)
Connects this socket to a remote socket address (IP address + port number).
voidconnect(InetAddress address, int port)
Connects the socket to a remote address for this socket.
voiddisconnect()
Disconnects the socket.
booleangetBroadcast()
Tests if SO_BROADCAST is enabled.
DatagramChannelgetChannel()
Returns the unique java.nio.channels.DatagramChannel object associated with this datagram socket, if any.
InetAddressgetInetAddress()
Returns the address to which this socket is connected.
InetAddressgetLocalAddress()
Gets the local address to which the socket is bound.
intgetLocalPort()
Returns the port number on the local host to which this socket is bound.
SocketAddressgetLocalSocketAddress()
Returns the address of the endpoint this socket is bound to.
intgetPort()
Returns the port number to which this socket is connected.
intgetReceiveBufferSize()
Get value of the SO_RCVBUF option for this DatagramSocket , that is the buffer size used by the platform for input on this DatagramSocket .
SocketAddressgetRemoteSocketAddress()
Returns the address of the endpoint this socket is connected to, or null if it is unconnected.
booleangetReuseAddress()
Tests if SO_REUSEADDR is enabled.
intgetSendBufferSize()
Get value of the SO_SNDBUF option for this DatagramSocket , that is the buffer size used by the platform for output on this DatagramSocket .
intgetSoTimeout()
Retrieve setting for SO_TIMEOUT.
intgetTrafficClass()
Gets traffic class or type-of-service in the IP datagram header for packets sent from this DatagramSocket.
booleanisBound()
Returns the binding state of the socket.
booleanisClosed()
Returns whether the socket is closed or not.
booleanisConnected()
Returns the connection state of the socket.
voidreceive(DatagramPacket p)
Receives a datagram packet from this socket.
voidsend(DatagramPacket p)
Sends a datagram packet from this socket.
voidsetBroadcast(boolean on)
Enable/disable SO_BROADCAST.
voidsetDatagramSocketImplFactory(DatagramSocketImplFactory fac)
Sets the datagram socket implementation factory for the application.
voidsetReceiveBufferSize(int size)
Sets the SO_RCVBUF option to the specified value for this DatagramSocket .
voidsetReuseAddress(boolean on)
Enable/disable the SO_REUSEADDR socket option.
voidsetSendBufferSize(int size)
Sets the SO_SNDBUF option to the specified value for this DatagramSocket .
voidsetSoTimeout(int timeout)
Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds.
voidsetTrafficClass(int tc)
Sets traffic class or type-of-service octet in the IP datagram header for datagrams sent from this DatagramSocket.