|
Chapter 15 The java.net Package |
|
DatagramSocketImpl
Name
DatagramSocketImpl
- Class Name:
-
java.net.DatagramSocketImpl
- Superclass:
-
java.lang.Object
- Immediate Subclasses:
-
None
- Interfaces Implemented:
-
None
- Availability:
-
New as of JDK 1.1
The DatagramSocketImpl class
is an abstract class that defines
the bulk of the methods that make the DatagramSocket
and MulticastSocket classes
work. Non-public subclasses
of DatagramSocketImpl provide
platform-specific implementations of datagram socket communication.
public abstract class java.net.DatagramSocketImpl
extends java.lang.Object {
// Variables
protected FileDescriptor fd;
protected int localPort;
// Protected Instance Methods
protected abstract void bind(int lport, InetAddress laddr);
protected abstract void close();
protected abstract void create();
protected FileDescriptor getFileDescriptor();
protected int getLocalPort();
protected abstract byte getTTL();
protected abstract void join(InetAddress inetaddr);
protected abstract void leave(InetAddress inetaddr);
protected abstract int peek(InetAddress i);
protected abstract void receive(DatagramPacket p);
protected abstract void send(DatagramPacket p);
protected abstract void setTTL(byte ttl);
}
- Description
-
The file descriptor that represents this socket.
- Description
-
The local port number of this socket.
- Parameters
-
- lport
-
A port number.
- laddr
-
A local address.
- Throws
-
- SocketException
-
If any kind of socket error occurs.
- Description
-
This method binds the socket to the given address and port. If the address
or the port is unavailable, an exception is thrown.
- Description
-
This method closes the socket, releasing any
system resources it holds.
- Throws
-
- SocketException
-
If a socket error occurs.
- Description
-
This method creates a socket that is not bound to an address and port.
- Returns
-
The file descriptor for this socket.
- Description
-
This method returns the file descriptor associated with this DatagramSocketImpl.
- Returns
-
The port number for this socket.
- Description
-
This method returns the local port to which this DatagramSocketImpl
is bound.
- Returns
-
The time-to-live (TTL) value for this socket.
- Throws
-
- IOException
-
If any kind of I/O error occurs.
- Description
-
This method returns the TTL value for this socket. This value is the number
of hops that an outgoing packet can traverse before it is discarded.
- Parameters
-
- inetaddr
-
The IP address of the group to join.
- Throws
-
- IOException
-
If any kind of I/O error occurs.
- Description
-
This method is used by MulticastSocket
to join a multicast group. An exception is thrown if the given address
is not a multicast address. While the socket is part of a group, it receives
all packets that are sent to the group.
- Parameters
-
- inetaddr
-
The IP address of the group to leave.
- Throws
-
- IOException
-
If any kind of I/O error occurs.
- Description
-
This method is used by MulticastSocket
to leave a multicast group. An exception is thrown if the given address
is not a multicast address.
- Parameters
-
- i
-
A reference to an InetAddress object.
- Returns
-
The port number of the next incoming packet.
- Throws
-
- IOException
-
If any kind of I/O error occurs.
- Description
-
This method places the address of the next incoming packet in the given
InetAddress
object. The method also returns the port number of the next incoming packet.
The method looks at the address of an incoming packet to
determine if it should be accepted.
- Parameters
-
- p
-
The DatagramPacket that receives incoming data.
- Throws
-
- IOException
-
If any kind of I/O error occurs.
- Description
-
This method receives a datagram packet on this socket. After this method
returns, the given DatagramPacket
contains the packet's data and length, and the sender's address
and port number. If the data that was sent is longer that the given packet's
data buffer, the data is truncated.
- Parameters
-
- p
-
The DatagramPacket to be sent.
- Throws
-
- IOException
-
If any kind of I/O error occurs.
- Description
-
This method sends a packet from this socket. The packet data, packet length,
destination address, and destination port number are specified by the given
DatagramPacket.
- Parameters
-
- ttl
-
The new TTL value for this socket.
- Throws
-
- IOException
-
If any kind of I/O error occurs.
- Description
-
This method is used to set the TTL value of the socket. The TTL value is
the number of hops that an outgoing packet can traverse before it is discarded.
DatagramPacket,
DatagramSocket,
FileDescriptor,
InetAddress,
IOException,
MulticastSocket
|
|