java.net
Class DatagramSocketImpl
java.lang.Object
|
+--java.net.DatagramSocketImpl
All Implemented Interfaces:
SocketOptions
This abstract class models a datagram socket implementation. An
actual implementation class would implement these methods, probably
via redirecting them to native code.
Written using on-line Java Platform 1.2 API Specification, as well
as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
Status: Believed complete and correct.
Since:Authors:- Aaron M. Renn (arenn@urbanophile.com)
- Warren Levy <warrenl@cygnus.com>
fd
protected FileDescriptor fd
The FileDescriptor object for this object.
localPort
protected int localPort
The local port to which this socket is bound
DatagramSocketImpl
public DatagramSocketImpl()
Default, no-argument constructor for subclasses to call.
bind
protected void bind(int lport, java.net.InetAddress laddr)
This method binds the socket to the specified local port and address.
Parameters:
Throws:
close
protected void close()
This methods closes the socket
connect
protected void connect(java.net.InetAddress address, int port)
Connects the socket to a host specified by address and port.
Since:Parameters:
Throws:
create
protected void create()
Creates a new datagram socket.
Throws:
disconnect
protected void disconnect()
Disconnects the socket.
Since:
getFileDescriptor
protected FileDescriptor getFileDescriptor()
Returns the FileDescriptor for this socket
getLocalPort
protected int getLocalPort()
Returns the local port this socket is bound to
getOption
public Object getOption(int option_id)
Returns the current setting of the specified option. The
Object
returned will be an Integer
for options
that have integer values. For options that are set to on or off, a
Boolean
will be returned. The option_id
is one of the defined constants in the superinterface.
Parameters:
Returns:
- The current value of the option
Throws:
getTTL
protected byte getTTL()
This method returns the current Time to Live (TTL) setting on this
socket. Use getTimeToLive()
instead.
Throws:
getTimeToLive
protected int getTimeToLive()
This method returns the current Time to Live (TTL) setting on this
socket.
Throws:
join
protected void join(java.net.InetAddress inetaddr)
Causes this socket to join the specified multicast group
Parameters:
Throws:
joinGroup
protected void joinGroup(java.net.SocketAddress mcastaddr, java.net.NetworkInterface netIf)
Causes this socket to join the specified multicast group on a specified
device
Since:Parameters:
Throws:
leave
protected void leave(java.net.InetAddress inetaddr)
Causes the socket to leave the specified multicast group.
Parameters:
Throws:
leaveGroup
protected void leaveGroup(java.net.SocketAddress mcastaddr, java.net.NetworkInterface netIf)
Leaves a multicast group
Since:Parameters:
Throws:
peek
protected int peek(java.net.InetAddress i)
Takes a peek at the next packet received in order to retrieve the
address of the sender
Parameters:
Returns:
- The port number of the sender of the packet
Throws:
peekData
protected int peekData(java.net.DatagramPacket p)
Takes a peek at the next packet received. This packet is not consumed.
With the next peekData/receive operation this packet will be read again.
Since:Parameters:
Returns:
- The port number of the sender of the packet.
Throws:
receive
protected void receive(java.net.DatagramPacket p)
Receives a packet of data from the network Will block until a packet
arrives. The packet info in populated into the passed in
DatagramPacket object.
Parameters:
Throws:
send
protected void send(java.net.DatagramPacket p)
Transmits the specified packet of data to the network. The destination
host and port should be encoded in the packet.
Parameters:
Throws:
setOption
public void setOption(int option_id, java.lang.Object val)
Sets the specified option on a socket to the passed in object. For
options that take an integer argument, the passed in object is an
Integer
. For options that are set to on or off, the
value passed will be a Boolean
. The option_id
parameter is one of the defined constants in the superinterface.
Parameters:
Throws:
setTTL
protected void setTTL(byte ttl)
Sets the Time to Live (TTL) setting on this socket to the specified
value. Use setTimeToLive(int)
instead.
Parameters:
Throws:
setTimeToLive
protected void setTimeToLive(int ttl)
Sets the Time to Live (TTL) setting on this socket to the specified
value.
Parameters:
Throws:
Written using on-line Java Platform 1.2 API Specification, as well as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
Status: Believed complete and correct.