The UDP ProtocolUDP ClientsUDP ServersThe DatagramPacket ClassThe ConstructorsConstructors for receiving datagramsConstructors for sending datagramsThe get Methodspublic InetAddress getAddress()public int getPort()public SocketAddress getSocketAddress()public byte[] getData()public int getLength()public int getOffset()The setter Methodspublic void setData(byte[] data)public void setData(byte[] data, int offset, int length)public void setAddress(InetAddress remote)public void setPort(int port)public void setAddress(SocketAddress remote)public void setLength(int length)The DatagramSocket ClassThe Constructorspublic DatagramSocket() throws SocketExceptionpublic DatagramSocket(int port) throws SocketExceptionpublic DatagramSocket(int port, InetAddress interface) throws SocketExceptionpublic DatagramSocket(SocketAddress interface) throws SocketExceptionprotected DatagramSocket(DatagramSocketImpl impl) throws SocketExceptionSending and Receiving Datagramspublic void send(DatagramPacket dp) throws IOExceptionpublic void receive(DatagramPacket dp) throws IOExceptionpublic void close()public int getLocalPort()public InetAddress getLocalAddress()public SocketAddress getLocalSocketAddress()Managing Connectionspublic void connect(InetAddress host, int port)public void disconnect()public int getPort()public InetAddress getInetAddress()public InetAddress getRemoteSocketAddress()Socket OptionsSO_TIMEOUTSO_RCVBUFSO_SNDBUFSO_REUSEADDRSO_BROADCASTIP_TOSSome Useful ApplicationsSimple UDP ClientsUDPServerA UDP Echo ClientDatagramChannelUsing DatagramChannelOpening a socketReceivingSendingConnectingReadingWritingClosingSocket Options // Java 7