gnu.java.net
Class PlainSocketImpl
- SocketOptions
Unless the application installs its own SocketImplFactory, this is the
default socket implemetation that will be used. It simply uses a
combination of Java and native routines to implement standard BSD
style sockets of family AF_INET and types SOCK_STREAM and SOCK_DGRAM
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 |
protected void | accept(SocketImpl impl) - Accepts a new connection on this socket and returns in in the
passed in SocketImpl.
|
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(String host, int port) - Connects to the remote hostname and port specified as arguments.
|
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 remote socket address with a specified timeout.
|
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()
|
protected InputStream | getInputStream() - Returns an InputStream object for reading from this socket.
|
InetSocketAddress | getLocalAddress()
|
int | getNativeFD()
|
Object | getOption(int optID) - Returns the current setting of the specified option.
|
protected OutputStream | getOutputStream() - Returns an OutputStream object for writing to this socket.
|
boolean | isInChannelOperation() - Indicates whether we should ignore whether any associated
channel is set to non-blocking mode.
|
protected void | listen(int queuelen) - Starts listening for connections on a socket.
|
protected void | sendUrgentData(int data)
|
void | setInChannelOperation(boolean b) - Sets our indicator of whether an I/O operation is being
initiated by a channel.
|
void | setOption(int optID, Object value) - Sets the specified option on a socket to the passed in object.
|
void | shutdownInput() - Flushes the input stream and closes it.
|
void | shutdownOutput() - Flushes the output stream and closes it.
|
accept , available , bind , close , connect , connect , connect , create , getFileDescriptor , getInetAddress , getInputStream , getLocalPort , getOutputStream , getPort , listen , sendUrgentData , shutdownInput , shutdownOutput , supportsUrgentData , toString |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
accept
protected void accept(SocketImpl impl)
throws IOException
Accepts a new connection on this socket and returns in in the
passed in SocketImpl.
- accept in interface SocketImpl
impl
- The SocketImpl object to accept this connection.
available
protected int available()
throws IOException
Returns the number of bytes that the caller can read from this socket
without blocking.
- available in interface SocketImpl
- The number of readable bytes before blocking
bind
protected void bind(InetAddress host,
int port)
throws IOException
Binds to the specified port on the specified addr. Note that this addr
must represent a local IP address. **** How bind to INADDR_ANY? ****
- bind in interface SocketImpl
port
- The port number to bind to
close
protected void close()
throws IOException
Closes the socket. This will cause any InputStream or OutputStream
objects for this Socket to be closed as well.
Note that if the SO_LINGER option is set on this socket, then the
operation could block.
- close in interface SocketImpl
connect
protected void connect(SocketAddress addr,
int timeout)
throws IOException
Connects to the remote socket address with a specified timeout.
- connect in interface SocketImpl
timeout
- The timeout to use for this connect, 0 means infinite.
create
public void create(boolean stream)
throws IOException
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.
- create in interface SocketImpl
stream
- true for a stream socket, false for a datagram socket
getOption
public Object getOption(int optID)
throws SocketException
Returns the current setting of the specified option. The Object returned
will be an Integer for options that have integer values. The option_id
is one of the defined constants in this interface.
- getOption in interface SocketOptions
- The current value of the option
isInChannelOperation
public final boolean isInChannelOperation()
Indicates whether we should ignore whether any associated
channel is set to non-blocking mode. Certain operations
throw an IllegalBlockingModeException
if the
associated channel is in non-blocking mode, except
if the operation is invoked by the channel itself.
listen
protected void listen(int queuelen)
throws IOException
Starts listening for connections on a socket. The queuelen 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.
- listen in interface SocketImpl
queuelen
- The length of the pending connection queue
setInChannelOperation
public final void setInChannelOperation(boolean b)
Sets our indicator of whether an I/O operation is being
initiated by a channel.
setOption
public void setOption(int optID,
Object value)
throws SocketException
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. The option_id parameter is one of the defined constants in
this interface.
- setOption in interface SocketOptions
PlainSocketImpl.java -- Default socket implementation
Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007
Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.