Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

java.net
Class ZDatagramSocketImpl  view ZDatagramSocketImpl download ZDatagramSocketImpl.java

java.lang.Object
  extended byjava.net.DatagramSocketImpl
      extended byjava.net.PlainDatagramSocketImpl
          extended byjava.net.ZDatagramSocketImpl
All Implemented Interfaces:
SocketOptions

public class ZDatagramSocketImpl
extends PlainDatagramSocketImpl

This class is the new datagram socket implementation used by the datagram socket factory in place of the plain-old one. It provides a replacement for the creation method and the send/receive pair.

Version:
1.0

Field Summary
(package private) static int _Jv_IP_MULTICAST_IF_
           
(package private) static int _Jv_IP_MULTICAST_IF2_
           
(package private) static int _Jv_IP_MULTICAST_LOOP_
           
(package private) static int _Jv_IP_TOS_
           
(package private) static int _Jv_SO_BINDADDR_
           
(package private) static int _Jv_SO_BROADCAST_
           
(package private) static int _Jv_SO_KEEPALIVE_
           
(package private) static int _Jv_SO_LINGER_
           
(package private) static int _Jv_SO_OOBINLINE_
           
(package private) static int _Jv_SO_RCVBUF_
           
(package private) static int _Jv_SO_REUSEADDR_
           
(package private) static int _Jv_SO_SNDBUF_
           
(package private) static int _Jv_SO_TIMEOUT_
           
(package private) static int _Jv_TCP_NODELAY_
           
protected  DConnector conn
          The connector responsible for real packet compression/decompression/handling.
(package private)  int fnum
           
(package private)  InetAddress localAddress
           
(package private)  int timeout
           
 
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
ZDatagramSocketImpl()
           
 
Method Summary
 void _receive(DatagramPacket p)
          This is a wrapper to the real receiving method.
 void _send(DatagramPacket p)
          This is a wrapper to the real sending method.
protected  void bind(int lport, InetAddress laddr)
          This method binds the socket to the specified local port and address.
protected  void close()
          This methods closes the socket
protected  void connect(InetAddress i, int port)
          Connects the socket to a host specified by address and port.
 void create()
          This method is responsible for socket creation.
protected  void disconnect()
          Disconnects the socket.
protected  void finalize()
          Called on an object by the Virtual Machine at most once, at some point after the Object is determined unreachable but before it is destroyed.
 java.lang.Object getOption(int optID)
          Returns the current setting of the specified option.
protected  int getTimeToLive()
          This method returns the current Time to Live (TTL) setting on this socket.
protected  byte getTTL()
          This method returns the current Time to Live (TTL) setting on this socket.
protected  void join(InetAddress inetaddr)
          Causes this socket to join the specified multicast group
protected  void joinGroup(SocketAddress mcastaddr, NetworkInterface netIf)
          Causes this socket to join the specified multicast group on a specified device
protected  void leave(InetAddress inetaddr)
          Causes the socket to leave the specified multicast group.
protected  void leaveGroup(SocketAddress mcastaddr, NetworkInterface netIf)
          Leaves a multicast group
protected  int peek(InetAddress i)
          Takes a peek at the next packet received in order to retrieve the address of the sender
protected  int peekData(DatagramPacket dp)
          Takes a peek at the next packet received.
 void receive(DatagramPacket p)
          This is an overloaded method used to receive packets.
 void send(DatagramPacket p)
          This is an overloaded method used to send packets.
 void setOption(int optID, java.lang.Object value)
          Sets the specified option on a socket to the passed in object.
protected  void setTimeToLive(int ttl)
          Sets the Time to Live (TTL) setting on this socket to the specified value.
protected  void setTTL(byte ttl)
          Sets the Time to Live (TTL) setting on this socket to the specified value.
 
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

conn

protected DConnector conn
The connector responsible for real packet compression/decompression/handling.

See Also:
DConnector

_Jv_TCP_NODELAY_

static final int _Jv_TCP_NODELAY_
See Also:
Constant Field Values

_Jv_SO_BINDADDR_

static final int _Jv_SO_BINDADDR_
See Also:
Constant Field Values

_Jv_SO_REUSEADDR_

static final int _Jv_SO_REUSEADDR_
See Also:
Constant Field Values

_Jv_SO_BROADCAST_

static final int _Jv_SO_BROADCAST_
See Also:
Constant Field Values

_Jv_SO_OOBINLINE_

static final int _Jv_SO_OOBINLINE_
See Also:
Constant Field Values

_Jv_IP_MULTICAST_IF_

static final int _Jv_IP_MULTICAST_IF_
See Also:
Constant Field Values

_Jv_IP_MULTICAST_IF2_

static final int _Jv_IP_MULTICAST_IF2_
See Also:
Constant Field Values

_Jv_IP_MULTICAST_LOOP_

static final int _Jv_IP_MULTICAST_LOOP_
See Also:
Constant Field Values

_Jv_IP_TOS_

static final int _Jv_IP_TOS_
See Also:
Constant Field Values

_Jv_SO_LINGER_

static final int _Jv_SO_LINGER_
See Also:
Constant Field Values

_Jv_SO_TIMEOUT_

static final int _Jv_SO_TIMEOUT_
See Also:
Constant Field Values

_Jv_SO_SNDBUF_

static final int _Jv_SO_SNDBUF_
See Also:
Constant Field Values

_Jv_SO_RCVBUF_

static final int _Jv_SO_RCVBUF_
See Also:
Constant Field Values

_Jv_SO_KEEPALIVE_

static final int _Jv_SO_KEEPALIVE_
See Also:
Constant Field Values

fnum

int fnum

localAddress

InetAddress localAddress

timeout

int timeout
Constructor Detail

ZDatagramSocketImpl

public ZDatagramSocketImpl()
Method Detail

create

public void create()
            throws SocketException
This method is responsible for socket creation. It calls directly the create method of the PlainDatagramSocketImpl class but starts up a new DConnector thread to let him handle packets.

Overrides:
create in class PlainDatagramSocketImpl

_receive

public void _receive(DatagramPacket p)
              throws java.io.IOException
This is a wrapper to the real receiving method. It is needed because we overloaded the receive method with our own.


receive

public void receive(DatagramPacket p)
             throws java.io.IOException
This is an overloaded method used to receive packets. It asks the connector (viewed as a queue) if there's a queued packet (eventually waiting) and the asks the connector to handle it (decompress, ack,etc).

Overrides:
receive in class PlainDatagramSocketImpl

_send

public void _send(DatagramPacket p)
           throws java.io.IOException
This is a wrapper to the real sending method. It is needed because we overloaded the method send with our own method.


send

public void send(DatagramPacket p)
          throws java.io.IOException
This is an overloaded method used to send packets. It asks the connector to send it.

Overrides:
send in class PlainDatagramSocketImpl

bind

protected void bind(int lport,
                    InetAddress laddr)
             throws SocketException
Description copied from class: DatagramSocketImpl
This method binds the socket to the specified local port and address.

Specified by:
bind in class DatagramSocketImpl

connect

protected void connect(InetAddress i,
                       int port)
                throws SocketException
Description copied from class: DatagramSocketImpl
Connects the socket to a host specified by address and port.

Overrides:
connect in class DatagramSocketImpl

disconnect

protected void disconnect()
Description copied from class: DatagramSocketImpl
Disconnects the socket.

Overrides:
disconnect in class DatagramSocketImpl

peek

protected int peek(InetAddress i)
            throws java.io.IOException
Description copied from class: DatagramSocketImpl
Takes a peek at the next packet received in order to retrieve the address of the sender

Specified by:
peek in class DatagramSocketImpl

peekData

protected int peekData(DatagramPacket dp)
                throws java.io.IOException
Description copied from class: DatagramSocketImpl
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.

Specified by:
peekData in class DatagramSocketImpl

setTimeToLive

protected void setTimeToLive(int ttl)
                      throws java.io.IOException
Description copied from class: DatagramSocketImpl
Sets the Time to Live (TTL) setting on this socket to the specified value.

Specified by:
setTimeToLive in class DatagramSocketImpl

getTimeToLive

protected int getTimeToLive()
                     throws java.io.IOException
Description copied from class: DatagramSocketImpl
This method returns the current Time to Live (TTL) setting on this socket.

Specified by:
getTimeToLive in class DatagramSocketImpl

setOption

public void setOption(int optID,
                      java.lang.Object value)
               throws SocketException
Description copied from interface: SocketOptions
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 optionId parameter is one of the defined constants in this interface.


getOption

public java.lang.Object getOption(int optID)
                           throws SocketException
Description copied from interface: SocketOptions
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 optionId parameter is one of the defined constants in this interface.


close

protected void close()
Description copied from class: DatagramSocketImpl
This methods closes the socket

Specified by:
close in class DatagramSocketImpl

getTTL

protected byte getTTL()
               throws java.io.IOException
Description copied from class: DatagramSocketImpl
This method returns the current Time to Live (TTL) setting on this socket. Use getTimeToLive() instead.

Specified by:
getTTL in class DatagramSocketImpl

setTTL

protected void setTTL(byte ttl)
               throws java.io.IOException
Description copied from class: DatagramSocketImpl
Sets the Time to Live (TTL) setting on this socket to the specified value. Use setTimeToLive(int) instead.

Specified by:
setTTL in class DatagramSocketImpl

join

protected void join(InetAddress inetaddr)
             throws java.io.IOException
Description copied from class: DatagramSocketImpl
Causes this socket to join the specified multicast group

Specified by:
join in class DatagramSocketImpl

leave

protected void leave(InetAddress inetaddr)
              throws java.io.IOException
Description copied from class: DatagramSocketImpl
Causes the socket to leave the specified multicast group.

Specified by:
leave in class DatagramSocketImpl

joinGroup

protected void joinGroup(SocketAddress mcastaddr,
                         NetworkInterface netIf)
                  throws java.io.IOException
Description copied from class: DatagramSocketImpl
Causes this socket to join the specified multicast group on a specified device

Specified by:
joinGroup in class DatagramSocketImpl

leaveGroup

protected void leaveGroup(SocketAddress mcastaddr,
                          NetworkInterface netIf)
                   throws java.io.IOException
Description copied from class: DatagramSocketImpl
Leaves a multicast group

Specified by:
leaveGroup in class DatagramSocketImpl

finalize

protected void finalize()
                 throws java.lang.Throwable
Description copied from class: java.lang.Object
Called on an object by the Virtual Machine at most once, at some point after the Object is determined unreachable but before it is destroyed. You would think that this means it eventually is called on every Object, but this is not necessarily the case. If execution terminates abnormally, garbage collection does not always happen. Thus you cannot rely on this method to always work. For finer control over garbage collection, use references from the java.lang.ref package.

Virtual Machines are free to not call this method if they can determine that it does nothing important; for example, if your class extends Object and overrides finalize to do simply super.finalize().

finalize() will be called by a java.lang.Thread that has no locks on any Objects, and may be called concurrently. There are no guarantees on the order in which multiple objects are finalized. This means that finalize() is usually unsuited for performing actions that must be thread-safe, and that your implementation must be use defensive programming if it is to always work.

If an Exception is thrown from finalize() during garbage collection, it will be patently ignored and the Object will still be destroyed.

It is allowed, although not typical, for user code to call finalize() directly. User invocation does not affect whether automatic invocation will occur. It is also permitted, although not recommended, for a finalize() method to "revive" an object by making it reachable from normal code again.

Unlike constructors, finalize() does not get called for an object's superclass unless the implementation specifically calls super.finalize().

The default implementation does nothing.