|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.net.SocketImpl java.net.PlainSocketImpl
Default Socket Implementation. This implementation does not implement any security checks. Note this class should NOT be public.
Field Summary | |
private boolean |
closePending
|
private int |
CONNECTION_NOT_RESET
|
private int |
CONNECTION_RESET
|
private int |
CONNECTION_RESET_PENDING
|
private Object |
fdLock
|
private int |
fdUseCount
|
private Object |
resetLock
|
private int |
resetState
|
private boolean |
shut_rd
|
static int |
SHUT_RD
|
private boolean |
shut_wr
|
static int |
SHUT_WR
|
private SocketInputStream |
socketInputStream
|
(package private) int |
timeout
|
private int |
trafficClass
|
Fields inherited from class java.net.SocketImpl |
address, fd, localport, port, serverSocket, socket |
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()
Constructs an empty instance. |
(package private) |
PlainSocketImpl(FileDescriptor fd)
Constructs an instance with the given file descriptor. |
Method Summary | |
protected void |
accept(SocketImpl s)
Accepts connections. |
FileDescriptor |
acquireFD()
|
protected int |
available()
Returns the number of bytes that can be read without blocking. |
protected void |
bind(InetAddress address,
int lport)
Binds the socket to the specified address of the specified local port. |
protected void |
close()
Closes the socket. |
protected void |
connect(InetAddress address,
int port)
Creates a socket and connects it to the specified address on the specified port. |
protected void |
connect(SocketAddress address,
int timeout)
Creates a socket and connects it to the specified address on the specified port. |
protected void |
connect(String host,
int port)
Creates a socket and connects it to the specified port on the specified host. |
private void |
connectToAddress(InetAddress address,
int port,
int timeout)
|
protected void |
create(boolean stream)
Creates a socket with a boolean that specifies whether this is a stream socket (true) or an unconnected UDP socket (false). |
private void |
doConnect(InetAddress address,
int port,
int timeout)
The workhorse of the connection operation. |
protected void |
finalize()
Cleans up if the user forgets to close it. |
protected InputStream |
getInputStream()
Gets an InputStream for this socket. |
Object |
getOption(int opt)
Fetch the value of an option. |
protected OutputStream |
getOutputStream()
Gets an OutputStream for this socket. |
int |
getTimeout()
|
private static void |
initProto()
|
boolean |
isClosedOrPending()
|
boolean |
isConnectionReset()
|
boolean |
isConnectionResetPending()
|
protected void |
listen(int count)
Listens, for a specified amount of time, for connections. |
void |
releaseFD()
|
protected void |
sendUrgentData(int data)
Send one byte of urgent data on the socket. |
void |
setConnectionReset()
|
void |
setConnectionResetPending()
|
(package private) void |
setInputStream(SocketInputStream in)
|
void |
setOption(int opt,
Object val)
Enable/disable the option specified by optID. |
protected void |
shutdownInput()
Shutdown read-half of the socket connection; |
protected void |
shutdownOutput()
Shutdown write-half of the socket connection; |
private void |
socketAccept(SocketImpl s)
|
private int |
socketAvailable()
|
private void |
socketBind(InetAddress address,
int port)
|
private void |
socketClose()
|
private void |
socketClose0(boolean useDeferredClose)
|
private void |
socketConnect(InetAddress address,
int port,
int timeout)
|
private void |
socketCreate(boolean isServer)
|
private int |
socketGetOption(int opt,
Object iaContainerObj)
|
private void |
socketListen(int count)
|
private void |
socketPreClose()
|
private void |
socketSendUrgentData(int data)
|
private void |
socketSetOption(int cmd,
boolean on,
Object value)
|
private void |
socketShutdown(int howto)
|
protected boolean |
supportsUrgentData()
Returns whether or not this SocketImpl supports sending urgent data. |
Methods inherited from class java.net.SocketImpl |
getFileDescriptor, getInetAddress, getLocalPort, getPort, getServerSocket, getSocket, reset, setServerSocket, setSocket, toString |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
int timeout
private int trafficClass
private boolean shut_rd
private boolean shut_wr
private SocketInputStream socketInputStream
private int fdUseCount
private Object fdLock
private boolean closePending
private int CONNECTION_NOT_RESET
private int CONNECTION_RESET_PENDING
private int CONNECTION_RESET
private int resetState
private Object resetLock
public static final int SHUT_RD
public static final int SHUT_WR
Constructor Detail |
PlainSocketImpl()
PlainSocketImpl(FileDescriptor fd)
Method Detail |
protected void create(boolean stream) throws IOException
create
in class SocketImpl
stream
- if true
, create a stream socket;
otherwise, create a datagram socket.
IOException
- if an I/O error occurs while creating the
socket.protected void connect(String host, int port) throws UnknownHostException, IOException
connect
in class SocketImpl
host
- the specified hostport
- the specified port
IOException
- if an I/O error occurs when connecting to the
remote host.
UnknownHostException
protected void connect(InetAddress address, int port) throws IOException
connect
in class SocketImpl
address
- the addressport
- the specified port
IOException
- if an I/O error occurs when attempting a
connection.protected void connect(SocketAddress address, int timeout) throws IOException
connect
in class SocketImpl
address
- the addresstimeout
- the timeout value in milliseconds, or zero for no timeout.
IOException
- if connection fails
IllegalArgumentException
- if address is null or is a
SocketAddress subclass not supported by this socketprivate void connectToAddress(InetAddress address, int port, int timeout) throws IOException
IOException
public void setOption(int opt, Object val) throws SocketException
SocketOptions
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.IntegerIf 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
s.setOption(TCP_NODELAY, new Boolean(false)); // OK - disables TCP_NODELAY s.setOption(SO_LINGER, new Boolean(false)); // OK - disables SO_LINGER
opt
- identifies the optionval
- 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 opt) 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); }
opt
- 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 doConnect(InetAddress address, int port, int timeout) throws IOException
IOException
protected void bind(InetAddress address, int lport) throws IOException
bind
in class SocketImpl
address
- the addresslport
- the port number.
IOException
- if an I/O error occurs when binding this socket.protected void listen(int count) throws IOException
listen
in class SocketImpl
count
- the amount of time to listen for connections
IOException
- if an I/O error occurs when creating the queue.protected void accept(SocketImpl s) throws IOException
accept
in class SocketImpl
s
- the connection
IOException
- if an I/O error occurs when accepting the
connection.protected InputStream getInputStream() throws IOException
getInputStream
in class SocketImpl
IOException
- if an I/O error occurs when creating the
input stream.void setInputStream(SocketInputStream in)
protected OutputStream getOutputStream() throws IOException
getOutputStream
in class SocketImpl
IOException
- if an I/O error occurs when creating the
output stream.protected int available() throws IOException
available
in class SocketImpl
IOException
- if an I/O error occurs when determining the
number of bytes available.protected void close() throws IOException
close
in class SocketImpl
IOException
- if an I/O error occurs when closing this socket.protected void shutdownInput() throws IOException
shutdownInput
in class SocketImpl
IOException
- if an I/O error occurs when shutting down this
socket.Socket.shutdownOutput()
,
Socket.close()
,
Socket.setSoLinger(boolean, int)
protected void shutdownOutput() throws IOException
shutdownOutput
in class SocketImpl
IOException
- if an I/O error occurs when shutting down this
socket.Socket.shutdownInput()
,
Socket.close()
,
Socket.setSoLinger(boolean, int)
protected boolean supportsUrgentData()
SocketImpl
supportsUrgentData
in class SocketImpl
SocketImpl.address
protected void sendUrgentData(int data) throws IOException
SocketImpl
sendUrgentData
in class SocketImpl
data
- The byte of data to send
IOException
- if there is an error
sending the data.protected void finalize() throws IOException
finalize
in class Object
IOException
public final FileDescriptor acquireFD()
public final void releaseFD()
public boolean isConnectionReset()
public boolean isConnectionResetPending()
public void setConnectionReset()
public void setConnectionResetPending()
public boolean isClosedOrPending()
public int getTimeout()
private void socketPreClose() throws IOException
IOException
private void socketClose() throws IOException
IOException
private void socketCreate(boolean isServer) throws IOException
IOException
private void socketConnect(InetAddress address, int port, int timeout) throws IOException
IOException
private void socketBind(InetAddress address, int port) throws IOException
IOException
private void socketListen(int count) throws IOException
IOException
private void socketAccept(SocketImpl s) throws IOException
IOException
private int socketAvailable() throws IOException
IOException
private void socketClose0(boolean useDeferredClose) throws IOException
IOException
private void socketShutdown(int howto) throws IOException
IOException
private static void initProto()
private void socketSetOption(int cmd, boolean on, Object value) throws SocketException
SocketException
private int socketGetOption(int opt, Object iaContainerObj) throws SocketException
SocketException
private void socketSendUrgentData(int data) throws IOException
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |