java::net::PlainSocketImpl Class Reference

Inheritance diagram for java::net::PlainSocketImpl:

Inheritance graph
java::net::SocketImpljava::net::SocketOptionsjava::lang::Interfacejava::lang::Object
[legend]
Collaboration diagram for java::net::PlainSocketImpl:

Collaboration graph
java::net::SocketImpljava::net::SocketOptionsjava::lang::Interfacejava::lang::ScopeAdapterjava::lang::Comparablejava::lang::Objectjava::lang::ObjectRefjava::lang::Syncjava::lang::Lock
[legend]

List of all members.


Detailed Description

Default Socket Implementation.

This implementation does not implement any security checks. Note this class should NOT be public.

Author:
Steven B. Byrne
Version:
1.56, 12/03/01

Public Member Functions

 PlainSocketImpl (const Ref< FileDescriptor > &fd=0)
 Constructs an instance with the given file descriptor.
 ~PlainSocketImpl ()
jint getTimeout () const
virtual void setOption (jint optID, const ObjectRef &value)
 Enable/disable the option specified by optID.
virtual ObjectRef getOption (jint optID) const
 Fetch the value of an option.
virtual void create (jboolean stream)
 Creates either a stream or a datagram socket.
virtual void connect (const String &host, jint port, jint timeout=0)
 Connects this socket to the specified port on the named host.
virtual void connect (const Ref< InetAddress > &address, jint port, jint timeout=0)
 Connects this socket to the specified port number on the specified host.
virtual void bind (const Ref< InetAddress > &host, jint port)
 Binds this socket to the specified port number on the specified host.
virtual void listen (jint backlog)
 Sets the maximum queue length for incoming connection indications (a request to connect) to the count argument.
virtual void accept (const Ref< SocketImpl > &s)
 Accepts a connection.
virtual Ref
< InputStream
getInputStream ()
 Returns an input stream for this socket.
virtual Ref
< OutputStream
getOutputStream ()
 Returns an output stream for this socket.
virtual jint available ()
 Returns the number of bytes that can be read from this socket without blocking.
virtual void close ()
 Closes this socket.
virtual void shutdownInput ()
 Places the input stream for this socket at "end of stream".
virtual void shutdownOutput ()
 Disables the output stream for this socket.
virtual jboolean supportsUrgentData () const
 Returns whether or not this SocketImpl supports sending urgent data.
virtual void sendUrgentData (jint data)
 Send one byte of urgent data on the socket.

Protected Attributes

jint timeout
jint typeOfService
Sync sync

Constructor & Destructor Documentation

java::net::PlainSocketImpl::PlainSocketImpl ( const Ref< FileDescriptor > &  fd = 0  ) 

Constructs an instance with the given file descriptor.

java::net::PlainSocketImpl::~PlainSocketImpl (  ) 


Member Function Documentation

jint java::net::PlainSocketImpl::getTimeout (  )  const

virtual void java::net::PlainSocketImpl::setOption ( jint  optID,
const ObjectRef value 
) [virtual]

Enable/disable the option specified by optID.

If the option is to be enabled, and it takes an option-specific "value", this is passed in value. The actual type of value is option-specific, and it is an error to pass something that isn't of the expected type:

 SocketImpl s;
 ...
 s.setOption(SO_LINGER, new Integer(10));
    // OK - set SO_LINGER w/ timeout of 10 sec.
 s.setOption(SO_LINGER, new Double(10));
    // ERROR - expects java.lang.Integer
If the requested option is binary, it can be set using this method by a java.lang.Boolean:
 s.setOption(TCP_NODELAY, new Boolean(true));
    // OK - enables TCP_NODELAY, a binary option
 

Any option can be disabled using this method with a Boolean(false):
 s.setOption(TCP_NODELAY, new Boolean(false));
    // OK - disables TCP_NODELAY
 s.setOption(SO_LINGER, new Boolean(false));
    // OK - disables SO_LINGER
 

For an option that has a notion of on and off, and requires a non-boolean parameter, setting its value to anything other than Boolean(false) implicitly enables it.
Throws SocketException if the option is unrecognized, the socket is closed, or some low-level error occurred
Parameters:
optID identifies the option
value the parameter of the socket option
Exceptions:
SocketException if the option is unrecognized, the socket is closed, or some low-level error occurred
See also:
getOption(int)

Implements java::net::SocketOptions.

virtual ObjectRef java::net::PlainSocketImpl::getOption ( jint  optID  )  const [virtual]

Fetch the value of an option.

Binary options will return java.lang.Boolean(true) if enabled, java.lang.Boolean(false) if disabled, e.g.:

 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);
 }
 

Parameters:
optID an int identifying the option to fetch
Returns:
the value of the option
Exceptions:
SocketException if the socket is closed
SocketException if optID is unknown along the protocol stack (including the SocketImpl)
See also:
setOption(int, java.lang.Object)

Implements java::net::SocketOptions.

virtual void java::net::PlainSocketImpl::create ( jboolean  stream  )  [virtual]

Creates either a stream or a datagram socket.

Parameters:
stream if true, create a stream socket; otherwise, create a datagram socket.
Exceptions:
IOException if an I/O error occurs while creating the socket.

Implements java::net::SocketImpl.

virtual void java::net::PlainSocketImpl::connect ( const String host,
jint  port,
jint  timeout = 0 
) [virtual]

Connects this socket to the specified port on the named host.

Parameters:
host the name of the remote host.
port the port number.
timeout the timeout value, in milliseconds, or zero for no timeout.
Exceptions:
IOException if an I/O error occurs when connecting to the remote host.

Implements java::net::SocketImpl.

virtual void java::net::PlainSocketImpl::connect ( const Ref< InetAddress > &  address,
jint  port,
jint  timeout = 0 
) [virtual]

Connects this socket to the specified port number on the specified host.

Parameters:
address the IP address of the remote host.
port the port number.
timeout the timeout value, in milliseconds, or zero for no timeout.
Exceptions:
IOException if an I/O error occurs when attempting a connection.

Implements java::net::SocketImpl.

virtual void java::net::PlainSocketImpl::bind ( const Ref< InetAddress > &  host,
jint  port 
) [virtual]

Binds this socket to the specified port number on the specified host.

Parameters:
host the IP address of the remote host.
port the port number.
Exceptions:
IOException if an I/O error occurs when binding this socket.

Implements java::net::SocketImpl.

virtual void java::net::PlainSocketImpl::listen ( jint  backlog  )  [virtual]

Sets the maximum queue length for incoming connection indications (a request to connect) to the count argument.

If a connection indication arrives when the queue is full, the connection is refused.

Parameters:
backlog the maximum length of the queue.
Exceptions:
IOException if an I/O error occurs when creating the queue.

Implements java::net::SocketImpl.

virtual void java::net::PlainSocketImpl::accept ( const Ref< SocketImpl > &  s  )  [virtual]

Accepts a connection.

Parameters:
s the accepted connection.
Exceptions:
IOException if an I/O error occurs when accepting the connection.

Implements java::net::SocketImpl.

virtual Ref<InputStream> java::net::PlainSocketImpl::getInputStream (  )  [virtual]

Returns an input stream for this socket.

Returns:
a stream for reading from this socket.
Exceptions:
IOException if an I/O error occurs when creating the input stream.

Implements java::net::SocketImpl.

virtual Ref<OutputStream> java::net::PlainSocketImpl::getOutputStream (  )  [virtual]

Returns an output stream for this socket.

Returns:
an output stream for writing to this socket.
Exceptions:
IOException if an I/O error occurs when creating the output stream.

Implements java::net::SocketImpl.

virtual jint java::net::PlainSocketImpl::available (  )  [virtual]

Returns the number of bytes that can be read from this socket without blocking.

Returns:
the number of bytes that can be read from this socket without blocking.
Exceptions:
IOException if an I/O error occurs when determining the number of bytes available.

Implements java::net::SocketImpl.

virtual void java::net::PlainSocketImpl::close (  )  [virtual]

Closes this socket.

Exceptions:
IOException if an I/O error occurs when closing this socket.

Implements java::net::SocketImpl.

virtual void java::net::PlainSocketImpl::shutdownInput (  )  [virtual]

Places the input stream for this socket at "end of stream".

Any data sent to this socket is acknowledged and then silently discarded.

If you read from a socket input stream after invoking shutdownInput() on the socket, the stream will return EOF.

Exceptions:
IOException if an I/O error occurs when shutting down this socket.
See also:
java.net.Socket::shutdownOutput()

java.net.Socket::close()

java.net.Socket::setSoLinger(boolean, int)

Reimplemented from java::net::SocketImpl.

virtual void java::net::PlainSocketImpl::shutdownOutput (  )  [virtual]

Disables the output stream for this socket.

For a TCP socket, any previously written data will be sent followed by TCP's normal connection termination sequence.

If you write to a socket output stream after invoking shutdownOutput() on the socket, the stream will throw an IOException.

Exceptions:
IOException if an I/O error occurs when shutting down this socket.
See also:
java.net.Socket::shutdownInput()

java.net.Socket::close()

java.net.Socket::setSoLinger(boolean, int)

Reimplemented from java::net::SocketImpl.

virtual jboolean java::net::PlainSocketImpl::supportsUrgentData (  )  const [virtual]

Returns whether or not this SocketImpl supports sending urgent data.

By default, false is returned unless the method is overridden in a sub-class

Returns:
true if urgent data supported
See also:
java.net.SocketImpl::address
Since:
1.4

Reimplemented from java::net::SocketImpl.

virtual void java::net::PlainSocketImpl::sendUrgentData ( jint  data  )  [virtual]

Send one byte of urgent data on the socket.

The byte to be sent is the low eight bits of the parameter

Parameters:
data The byte of data to send
Exceptions:
IOException if there is an error sending the data.
Since:
1.4

Implements java::net::SocketImpl.


Member Data Documentation

jint java::net::PlainSocketImpl::timeout [protected]

jint java::net::PlainSocketImpl::typeOfService [protected]

Sync java::net::PlainSocketImpl::sync [protected]


The documentation for this class was generated from the following file:
Generated on Fri May 16 11:56:44 2008 for CrossPlatformJavaLikeC++API by  doxygen 1.5.3