public abstract class java.net
DatagramSocketImpl


Show All Login
Java SE 6
  
Implements: SocketOptions
Details
Abstract datagram and multicast socket implementation base class.
sinceJDK1.1

Fields
protected int localPort
The local port number.
protected java.io.FileDescriptor fd
The file descriptor object.

Constructors
public DatagramSocketImpl()

Methods
abstract protected void bind(int lport, InetAddress laddr) throws SocketException Details
Binds a datagram socket to a local port and address.
lportthe local port
laddrthe local address
ThrowsSocketException: if there is an error in the underlying protocol, such as a TCP error.
abstract protected void close()
Close the socket.
protected void connect(InetAddress address, int port) throws SocketException Details
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.
addressthe remote InetAddress to connect to
portthe remote port number
ThrowsSocketException: may be thrown if the socket cannot be connected to the remote destination
since1.4

abstract protected void create() throws SocketException Details
Creates a datagram socket.
ThrowsSocketException: if there is an error in the underlying protocol, such as a TCP error.
protected void disconnect() Details
Disconnects a datagram socket from its remote destination.
since1.4
abstract protected void join(InetAddress inetaddr) throws IOException Details
Join the multicast group.
inetaddrmulticast address to join.
ThrowsIOException: if an I/O exception occurs while joining the multicast group.
abstract protected void joinGroup(SocketAddress mcastaddr, NetworkInterface netIf) throws IOException Details
Join the multicast group.
mcastaddraddress to join.
netIfspecifies the local interface to receive multicast datagram packets
ThrowsIOException: if an I/O exception occurs while joining the multicast group
since1.4
abstract protected void leave(InetAddress inetaddr) throws IOException Details
Leave the multicast group.
inetaddrmulticast address to leave.
ThrowsIOException: if an I/O exception occurs while leaving the multicast group.
abstract protected void leaveGroup(SocketAddress mcastaddr, NetworkInterface netIf) throws IOException Details
Leave the multicast group.
mcastaddraddress to leave.
netIfspecified the local interface to leave the group at
ThrowsIOException: if an I/O exception occurs while leaving the multicast group
since1.4
abstract protected int peek(InetAddress i) throws IOException Details
Peek at the packet to see who it is from. Updates the specified InetAddress to the address which the packet came from.
ian InetAddress object
returnthe port number which the packet came from.
ThrowsIOException: if an I/O exception occurs
ThrowsPortUnreachableException: may be thrown if the socket is connected to a currently unreachable destination. Note, there is no guarantee that the exception will be thrown.
abstract protected int peekData(DatagramPacket p) throws IOException Details
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.
pthe Packet Received.
returnthe port number which the packet came from.
ThrowsIOException: if an I/O exception occurs
ThrowsPortUnreachableException: may be thrown if the socket is connected to a currently unreachable destination. Note, there is no guarantee that the exception will be thrown.
since1.4
abstract protected void receive(DatagramPacket p) throws IOException Details
Receive the datagram packet.
pthe Packet Received.
ThrowsIOException: if an I/O exception occurs while receiving the datagram packet.
ThrowsPortUnreachableException: may be thrown if the socket is connected to a currently unreachable destination. Note, there is no guarantee that the exception will be thrown.
abstract protected void send(DatagramPacket p) throws IOException Details
Sends a datagram packet. The packet contains the data and the destination address to send the packet to.
pthe packet to be sent.
ThrowsIOException: if an I/O exception occurs while sending the datagram packet.
ThrowsPortUnreachableException: may be thrown if the socket is connected to a currently unreachable destination. Note, there is no guarantee that the exception will be thrown.

Properties
protected java.io.FileDescriptor getFileDescriptor() Details
Gets the datagram socket file descriptor.
returna FileDescriptor object representing the datagram socket file descriptor
protected int getLocalPort() Details
Gets the local port.
returnan int representing the local port value
abstract protected void setTimeToLive(int ttl) throws IOException Details
Set the TTL (time-to-live) option.
ttlan int specifying the time-to-live value
ThrowsIOException: if an I/O exception occurs while setting the time-to-live option.
See also getTimeToLive()
abstract protected int getTimeToLive() throws IOException Details
Retrieve the TTL (time-to-live) option.
ThrowsIOException: if an I/O exception occurs while retrieving the time-to-live option
returnan int representing the time-to-live value
See also setTimeToLive(int)
abstract protected void
setTTL(byte ttl) throws IOException
Details
Set the TTL (time-to-live) option.
ttla byte specifying the TTL value
deprecateduse setTimeToLive instead.
ThrowsIOException: if an I/O exception occurs while setting the time-to-live option.
See also getTTL()
abstract protected byte
getTTL() throws IOException
Details
Retrieve the TTL (time-to-live) option.
ThrowsIOException: if an I/O exception occurs while retrieving the time-to-live option
deprecateduse getTimeToLive instead.
returna byte representing the TTL value
See also setTTL(byte)