|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.net.DatagramSocketImpl java.net.PlainDatagramSocketImpl
Concrete datagram and multicast socket implementation base class. Note: This is not a public class, so that applets cannot call into the implementation directly and hence cannot bypass the security checks present in the DatagramSocket and MulticastSocket classes.
Field Summary | |
private boolean |
connected
|
private InetAddress |
connectedAddress
|
private int |
connectedPort
|
private boolean |
loopbackMode
|
private int |
multicastInterface
|
private int |
timeout
|
private int |
trafficClass
|
private int |
ttl
|
Fields inherited from class java.net.DatagramSocketImpl |
fd, localPort |
Fields inherited from interface java.net.SocketOptions |
IP_MULTICAST_IF, IP_MULTICAST_IF2, IP_MULTICAST_LOOP, IP_TOS, SO_BINDADDR, SO_BROADCAST, SO_KEEPALIVE, SO_LINGER, SO_OOBINLINE, SO_RCVBUF, SO_REUSEADDR, SO_SNDBUF, SO_TIMEOUT, TCP_NODELAY |
Constructor Summary | |
(package private) |
PlainDatagramSocketImpl()
|
Method Summary | |
protected void |
bind(int lport,
InetAddress laddr)
Binds a datagram socket to a local port. |
protected void |
close()
Close the socket. |
protected void |
connect(InetAddress address,
int port)
Connects a datagram socket to a remote destination. |
private void |
connect0(InetAddress address,
int port)
|
protected void |
create()
Creates a datagram socket |
private void |
datagramSocketClose()
|
private void |
datagramSocketCreate()
|
protected void |
disconnect()
Disconnects a previously connected socket. |
private void |
disconnect0()
|
protected void |
finalize()
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. |
Object |
getOption(int optID)
Fetch the value of an option. |
protected int |
getTimeToLive()
Get the TTL (time-to-live) option. |
protected byte |
getTTL()
Get the TTL (time-to-live) option. |
private static void |
init()
Perform class load-time initializations. |
protected void |
join(InetAddress inetaddr)
Join the multicast group. |
private void |
join(InetAddress inetaddr,
NetworkInterface netIf)
|
protected void |
joinGroup(SocketAddress mcastaddr,
NetworkInterface netIf)
Join the multicast group. |
protected void |
leave(InetAddress inetaddr)
Leave the multicast group. |
private void |
leave(InetAddress inetaddr,
NetworkInterface netIf)
|
protected void |
leaveGroup(SocketAddress mcastaddr,
NetworkInterface netIf)
Leave the multicast group. |
protected int |
peek(InetAddress i)
Peek at the packet to see who it is from. |
protected int |
peekData(DatagramPacket p)
Peek at the packet to see who it is from. |
protected void |
receive(DatagramPacket p)
Receive the datagram packet. |
protected void |
send(DatagramPacket p)
Sends a datagram packet. |
void |
setOption(int optID,
Object o)
set a value - since we only support (setting) binary options here, o must be a Boolean |
protected void |
setTimeToLive(int ttl)
Set the TTL (time-to-live) option. |
protected void |
setTTL(byte ttl)
Set the TTL (time-to-live) option. |
private Object |
socketGetOption(int opt)
|
private void |
socketSetOption(int opt,
Object val)
|
Methods inherited from class java.net.DatagramSocketImpl |
getFileDescriptor, getLocalPort |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private int timeout
private int trafficClass
private boolean connected
private InetAddress connectedAddress
private int connectedPort
private int multicastInterface
private boolean loopbackMode
private int ttl
Constructor Detail |
PlainDatagramSocketImpl()
Method Detail |
protected void create() throws SocketException
create
in class DatagramSocketImpl
SocketException
- if there is an error in the
underlying protocol, such as a TCP error.protected void bind(int lport, InetAddress laddr) throws SocketException
bind
in class DatagramSocketImpl
lport
- the local portladdr
- the local address
SocketException
- if there is an error in the
underlying protocol, such as a TCP error.protected void send(DatagramPacket p) throws IOException
send
in class DatagramSocketImpl
p
- the packet to be sent.
IOException
- if an I/O exception occurs while sending the
datagram packet.protected void connect(InetAddress address, int port) throws SocketException
connect
in class DatagramSocketImpl
address
- the remote InetAddress to connect toport
- the remote port number
SocketException
- may be thrown if the socket cannot be
connected to the remote destinationprotected void disconnect()
disconnect
in class DatagramSocketImpl
protected int peek(InetAddress i) throws IOException
peek
in class DatagramSocketImpl
i
- an InetAddress object
IOException
- if an I/O exception occursprotected int peekData(DatagramPacket p) throws IOException
DatagramSocketImpl
peekData
in class DatagramSocketImpl
p
- the Packet Received.
IOException
- if an I/O exception occursprotected void receive(DatagramPacket p) throws IOException
receive
in class DatagramSocketImpl
p
- the Packet Received.
IOException
- if an I/O exception occurs
while receiving the datagram packet.protected void setTimeToLive(int ttl) throws IOException
setTimeToLive
in class DatagramSocketImpl
ttl
- an int specifying the time-to-live value
IOException
- if an I/O exception occurs
while setting the time-to-live option.DatagramSocketImpl.getTimeToLive()
protected int getTimeToLive() throws IOException
getTimeToLive
in class DatagramSocketImpl
IOException
- if an I/O exception occurs
while retrieving the time-to-live optionDatagramSocketImpl.setTimeToLive(int)
protected void setTTL(byte ttl) throws IOException
setTTL
in class DatagramSocketImpl
ttl
- a byte specifying the TTL value
IOException
- if an I/O exception occurs while setting
the time-to-live option.DatagramSocketImpl.getTTL()
protected byte getTTL() throws IOException
getTTL
in class DatagramSocketImpl
IOException
- if an I/O exception occurs
while retrieving the time-to-live optionDatagramSocketImpl.setTTL(byte)
protected void join(InetAddress inetaddr) throws IOException
join
in class DatagramSocketImpl
inetaddr
- multicast address to join.
IOException
- if an I/O exception occurs
while joining the multicast group.protected void leave(InetAddress inetaddr) throws IOException
leave
in class DatagramSocketImpl
inetaddr
- multicast address to leave.
IOException
- if an I/O exception occurs
while leaving the multicast group.protected void joinGroup(SocketAddress mcastaddr, NetworkInterface netIf) throws IOException
joinGroup
in class DatagramSocketImpl
netIf
- specifies the local interface to receive multicast
datagram packetsmcastaddr
- address to join.
IllegalArgumentException
- if mcastaddr is null or is a
SocketAddress subclass not supported by this socket
IOException
- if an I/O exception occurs while joining
the multicast groupprivate void join(InetAddress inetaddr, NetworkInterface netIf) throws IOException
IOException
protected void leaveGroup(SocketAddress mcastaddr, NetworkInterface netIf) throws IOException
leaveGroup
in class DatagramSocketImpl
netIf
- specified the local interface to leave the group atmcastaddr
- address to leave.
IllegalArgumentException
- if mcastaddr is null or is a
SocketAddress subclass not supported by this socket
IOException
- if an I/O exception occurs while leaving
the multicast groupprivate void leave(InetAddress inetaddr, NetworkInterface netIf) throws IOException
IOException
protected void close()
close
in class DatagramSocketImpl
protected void finalize()
Object
finalize
method to dispose of
system resources or to perform other cleanup.
The general contract of finalize is that it is invoked if and when the JavaTM virtual machine has determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, except as a result of an action taken by the finalization of some other object or class which is ready to be finalized. The finalize method may take any action, including making this object available again to other threads; the usual purpose of finalize, however, is to perform cleanup actions before the object is irrevocably discarded. For example, the finalize method for an object that represents an input/output connection might perform explicit I/O transactions to break the connection before the object is permanently discarded.
The finalize method of class Object performs no special action; it simply returns normally. Subclasses of Object may override this definition.
The Java programming language does not guarantee which thread will invoke the finalize method for any given object. It is guaranteed, however, that the thread that invokes finalize will not be holding any user-visible synchronization locks when finalize is invoked. If an uncaught exception is thrown by the finalize method, the exception is ignored and finalization of that object terminates.
After the finalize method has been invoked for an object, no further action is taken until the Java virtual machine has again determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, including possible actions by other objects or classes which are ready to be finalized, at which point the object may be discarded.
The finalize method is never invoked more than once by a Java virtual machine for any given object.
Any exception thrown by the finalize
method causes
the finalization of this object to be halted, but is otherwise
ignored.
finalize
in class Object
public void setOption(int optID, Object o) throws SocketException
optID
- identifies the optiono
- the parameter of the socket option
SocketException
- if the option is unrecognized,
the socket is closed, or some low-level error occurredSocketOptions.getOption(int)
public Object getOption(int optID) throws SocketException
SocketOptions
SocketImpl s; ... Boolean noDelay = (Boolean)(s.getOption(TCP_NODELAY)); if (noDelay.booleanValue()) { // true if TCP_NODELAY is enabled... ... }
For options that take a particular type as a parameter, getOption(int) will return the paramter's value, else it will return java.lang.Boolean(false):
Object o = s.getOption(SO_LINGER); if (o instanceof Integer) { System.out.print("Linger time is " + ((Integer)o).intValue()); } else { // the true type of o is java.lang.Boolean(false); }
optID
- an int
identifying the option to fetch
SocketException
- if optID is unknown along the
protocol stack (including the SocketImpl)SocketOptions.setOption(int, java.lang.Object)
private void datagramSocketCreate() throws SocketException
SocketException
private void datagramSocketClose()
private void socketSetOption(int opt, Object val) throws SocketException
SocketException
private Object socketGetOption(int opt) throws SocketException
SocketException
private void connect0(InetAddress address, int port) throws SocketException
SocketException
private void disconnect0()
private static void init()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |