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

Quick Search    Search Deep

java.net
Class PlainSocketImpl  view PlainSocketImpl download PlainSocketImpl.java

java.lang.Object
  extended byjava.net.SocketImpl
      extended byjava.net.PlainSocketImpl
All Implemented Interfaces:
SocketOptions
Direct Known Subclasses:
ZSocketImpl

class PlainSocketImpl
extends SocketImpl

The standard GCJ socket implementation. 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.


Nested Class Summary
(package private)  class PlainSocketImpl.SocketInputStream
          A stream which reads from the socket implementation.
(package private)  class PlainSocketImpl.SocketOutputStream
          A stream which writes to the socket implementation.
 
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_
           
(package private)  int fnum
          The OS file handle representing the socket.
private  java.io.InputStream in
          A cached copy of the in stream for reading from the socket.
(package private)  InetAddress localAddress
           
private  java.io.OutputStream out
          A cached copy of the out stream for writing to the socket.
(package private)  int timeout
           
 
Fields inherited from class java.net.SocketImpl
address, fd, localport, port
 
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) PlainSocketImpl()
           
 
Method Summary
private  void accept(PlainSocketImpl s)
           
protected  void accept(SocketImpl s)
          Accepts a connection on this socket.
protected  int available()
          Returns the number of bytes that the caller can read from this socket without blocking.
protected  void bind(InetAddress host, int port)
          Binds to the specified port on the specified addr.
protected  void close()
          Closes the socket.
protected  void connect(InetAddress host, int port)
          Connects to the remote address and port specified as arguments.
protected  void connect(SocketAddress addr, int timeout)
          Connects to the socket to the host specified in address.
protected  void connect(java.lang.String host, int port)
          Connects to the remote hostname and port specified as arguments.
protected  void create(boolean stream)
          Creates a new socket that is not bound to any local address/port and is not connected to any remote address/port.
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.
protected  java.io.InputStream getInputStream()
          Returns an InputStream object for reading from this socket.
 java.lang.Object getOption(int optID)
          Returns the current setting of the specified option.
protected  java.io.OutputStream getOutputStream()
          Returns an OutputStream object for writing to this socket
protected  void listen(int backlog)
          Starts listening for connections on a socket.
private  int read()
           
private  int read(byte[] buffer, int offset, int count)
           
protected  void sendUrgentData(int data)
          Sends one byte of urgent data to the socket.
 void setOption(int optID, java.lang.Object value)
          Sets the specified option on a socket to the passed in object.
 void shutdownInput()
          Shut down the input side of this socket.
 void shutdownOutput()
          Shut down the output side of this socket.
private  void write(byte[] buffer, int offset, int count)
           
private  void write(int c)
           
 
Methods inherited from class java.net.SocketImpl
getFileDescriptor, getInetAddress, getLocalPort, getPort, supportsUrgentData, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_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
The OS file handle representing the socket. This is used for reads and writes to/from the socket and to close it. When the socket is closed this is reset to -1.


timeout

int timeout

localAddress

InetAddress localAddress

in

private java.io.InputStream in
A cached copy of the in stream for reading from the socket.


out

private java.io.OutputStream out
A cached copy of the out stream for writing to the socket.

Constructor Detail

PlainSocketImpl

PlainSocketImpl()
Method Detail

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.


shutdownInput

public void shutdownInput()
                   throws java.io.IOException
Description copied from class: SocketImpl
Shut down the input side of this socket. Subsequent reads will return end-of-file.

Overrides:
shutdownInput in class SocketImpl

shutdownOutput

public void shutdownOutput()
                    throws java.io.IOException
Description copied from class: SocketImpl
Shut down the output side of this socket. Subsequent writes will fail with an IOException.

Overrides:
shutdownOutput in class SocketImpl

create

protected void create(boolean stream)
               throws java.io.IOException
Description copied from class: SocketImpl
Creates a new socket that is not bound to any local address/port and is not connected to any remote address/port. This will be created as a stream socket if the stream parameter is true, or a datagram socket if the stream parameter is false.

Specified by:
create in class SocketImpl

connect

protected void connect(java.lang.String host,
                       int port)
                throws java.io.IOException
Description copied from class: SocketImpl
Connects to the remote hostname and port specified as arguments.

Specified by:
connect in class SocketImpl

connect

protected void connect(InetAddress host,
                       int port)
                throws java.io.IOException
Description copied from class: SocketImpl
Connects to the remote address and port specified as arguments.

Specified by:
connect in class SocketImpl

connect

protected void connect(SocketAddress addr,
                       int timeout)
                throws java.io.IOException
Description copied from class: SocketImpl
Connects to the socket to the host specified in address. This method blocks until successful connected or the timeout occurs. A timeout of zero means no timout.

Specified by:
connect in class SocketImpl

bind

protected void bind(InetAddress host,
                    int port)
             throws java.io.IOException
Description copied from class: SocketImpl
Binds to the specified port on the specified addr. Note that this addr must represent a local IP address.

Note that it is unspecified how to bind to all interfaces on the localhost (INADDR_ANY).

Specified by:
bind in class SocketImpl

listen

protected void listen(int backlog)
               throws java.io.IOException
Description copied from class: SocketImpl
Starts listening for connections on a socket. The backlog parameter is how many pending connections will queue up waiting to be serviced before being accept'ed. If the queue of pending requests exceeds this number, additional connections will be refused.

Specified by:
listen in class SocketImpl

accept

private void accept(PlainSocketImpl s)
             throws java.io.IOException

accept

protected void accept(SocketImpl s)
               throws java.io.IOException
Description copied from class: SocketImpl
Accepts a connection on this socket.

Specified by:
accept in class SocketImpl

available

protected int available()
                 throws java.io.IOException
Description copied from class: SocketImpl
Returns the number of bytes that the caller can read from this socket without blocking.

Specified by:
available in class SocketImpl

close

protected void close()
              throws java.io.IOException
Description copied from class: SocketImpl
Closes the socket. This will normally cause any resources, such as the InputStream, OutputStream and associated file descriptors to be freed.

Note that if the SO_LINGER option is set on this socket, then the operation could block.

Specified by:
close in class SocketImpl

sendUrgentData

protected void sendUrgentData(int data)
                       throws java.io.IOException
Description copied from class: SocketImpl
Sends one byte of urgent data to the socket.

Specified by:
sendUrgentData in class SocketImpl

read

private int read()
          throws java.io.IOException

read

private int read(byte[] buffer,
                 int offset,
                 int count)
          throws java.io.IOException

write

private void write(int c)
            throws java.io.IOException

write

private void write(byte[] buffer,
                   int offset,
                   int count)
            throws java.io.IOException

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.


getInputStream

protected java.io.InputStream getInputStream()
                                      throws java.io.IOException
Description copied from class: SocketImpl
Returns an InputStream object for reading from this socket.

Specified by:
getInputStream in class SocketImpl

getOutputStream

protected java.io.OutputStream getOutputStream()
                                        throws java.io.IOException
Description copied from class: SocketImpl
Returns an OutputStream object for writing to this socket

Specified by:
getOutputStream in class SocketImpl