public abstract class DatagramSocketImpl extends Object implements SocketOptions
Abstract datagram and multicast socket implementation base class.
protected int localPort
The local port number.
protected FileDescriptor fd
The file descriptor object.
public DatagramSocketImpl()
protected abstract void create()
throws SocketException Creates a datagram socket.
SocketException - if there is an error in the underlying protocol, such as a TCP error.protected abstract void bind(int lport,
InetAddress laddr)
throws SocketException Binds a datagram socket to a local port and address.
lport - the local portladdr - the local addressSocketException - if there is an error in the underlying protocol, such as a TCP error.protected abstract void send(DatagramPacket p)
throws IOException Sends a datagram packet. The packet contains the data and the destination address to send the packet to.
p - the packet to be sent.IOException - if an I/O exception occurs while sending the datagram packet.PortUnreachableException - may be thrown if the socket is connected to a currently unreachable destination. Note, there is no guarantee that the exception will be thrown.protected void connect(InetAddress address,
int port)
throws SocketException Connects a datagram socket to a remote destination. This associates the remote address with the local socket so that datagrams may only be sent to this destination and received from this destination. This may be overridden to call a native system connect.
If the remote destination to which the socket is connected does not exist, or is otherwise unreachable, and if an ICMP destination unreachable packet has been received for that address, then a subsequent call to send or receive may throw a PortUnreachableException. Note, there is no guarantee that the exception will be thrown.
address - the remote InetAddress to connect toport - the remote port numberSocketException - may be thrown if the socket cannot be connected to the remote destinationprotected void disconnect()
Disconnects a datagram socket from its remote destination.
protected abstract int peek(InetAddress i)
throws IOException Peek at the packet to see who it is from. Updates the specified InetAddress to the address which the packet came from.
i - an InetAddress objectIOException - if an I/O exception occursPortUnreachableException - may be thrown if the socket is connected to a currently unreachable destination. Note, there is no guarantee that the exception will be thrown.protected abstract int peekData(DatagramPacket p)
throws IOException Peek at the packet to see who it is from. The data is copied into the specified DatagramPacket. The data is returned, but not consumed, so that a subsequent peekData/receive operation will see the same data.
p - the Packet Received.IOException - if an I/O exception occursPortUnreachableException - may be thrown if the socket is connected to a currently unreachable destination. Note, there is no guarantee that the exception will be thrown.protected abstract void receive(DatagramPacket p)
throws IOException Receive the datagram packet.
p - the Packet Received.IOException - if an I/O exception occurs while receiving the datagram packet.PortUnreachableException - may be thrown if the socket is connected to a currently unreachable destination. Note, there is no guarantee that the exception will be thrown.@Deprecated
protected abstract void setTTL(byte ttl)
throws IOException Deprecated. use setTimeToLive instead.
Set the TTL (time-to-live) option.
ttl - a byte specifying the TTL valueIOException - if an I/O exception occurs while setting the time-to-live option.getTTL()@Deprecated
protected abstract byte getTTL()
throws IOException Deprecated. use getTimeToLive instead.
Retrieve the TTL (time-to-live) option.
IOException - if an I/O exception occurs while retrieving the time-to-live optionsetTTL(byte)protected abstract void setTimeToLive(int ttl)
throws IOException Set the TTL (time-to-live) option.
ttl - an int specifying the time-to-live valueIOException - if an I/O exception occurs while setting the time-to-live option.getTimeToLive()protected abstract int getTimeToLive()
throws IOException Retrieve the TTL (time-to-live) option.
int representing the time-to-live valueIOException - if an I/O exception occurs while retrieving the time-to-live optionsetTimeToLive(int)protected abstract void join(InetAddress inetaddr)
throws IOException Join the multicast group.
inetaddr - multicast address to join.IOException - if an I/O exception occurs while joining the multicast group.protected abstract void leave(InetAddress inetaddr)
throws IOException Leave the multicast group.
inetaddr - multicast address to leave.IOException - if an I/O exception occurs while leaving the multicast group.protected abstract void joinGroup(SocketAddress mcastaddr,
NetworkInterface netIf)
throws IOException Join the multicast group.
mcastaddr - address to join.netIf - specifies the local interface to receive multicast datagram packetsIOException - if an I/O exception occurs while joining the multicast groupprotected abstract void leaveGroup(SocketAddress mcastaddr,
NetworkInterface netIf)
throws IOException Leave the multicast group.
mcastaddr - address to leave.netIf - specified the local interface to leave the group atIOException - if an I/O exception occurs while leaving the multicast groupprotected abstract void close()
Close the socket.
protected int getLocalPort()
Gets the local port.
int representing the local port valueprotected FileDescriptor getFileDescriptor()
Gets the datagram socket file descriptor.
FileDescriptor object representing the datagram socket file descriptor
© 1993–2017, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.