|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.net.SocketImpl
public abstract class SocketImpl
The abstract superclass of all classes that implement streaming sockets.
Streaming sockets are wrapped by two classes, ServerSocket and Socket at the
server and client end of a connection respectively. At the server there are
two types of sockets engaged in communication, the ServerSocket
on a well known port (hereafter refered to as the listener) used to establish
a connection and the resulting Socket (hereafter refered to as
host).
Some of the SocketImpl instance variable values must be
interpreted in the context of the wrapper. See the getter methods for these
details.
| Field Summary | |
|---|---|
protected InetAddress |
address
|
protected FileDescriptor |
fd
|
protected int |
localport
|
(package private) org.apache.harmony.luni.platform.INetworkSystem |
netImpl
|
protected int |
port
|
protected int |
receiveTimeout
|
(package private) boolean |
shutdownInput
|
(package private) boolean |
streaming
|
| 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 | |
|---|---|
SocketImpl()
Construct a connection-oriented SocketImpl. |
|
| Method Summary | |
|---|---|
protected abstract void |
accept(SocketImpl newSocket)
Accepts a connection on the provided socket. |
protected abstract int |
available()
Answer the number of bytes that may be read from this socket without blocking. |
protected abstract void |
bind(InetAddress address,
int port)
Binds this socket to the specified local host/port. |
protected abstract void |
close()
Close the socket. |
protected abstract void |
connect(InetAddress address,
int port)
Connects this socket to the specified remote host address/port. |
protected abstract void |
connect(SocketAddress remoteAddr,
int timeout)
Connect the socket to the host/port specified by the SocketAddress with a specified timeout. |
protected abstract void |
connect(String host,
int port)
Connects this socket to the specified remote host/port. |
protected abstract void |
create(boolean isStreaming)
Creates a new unconnected socket. |
protected FileDescriptor |
getFileDescriptor()
Answer the socket's file descriptor. |
protected InetAddress |
getInetAddress()
Answer the socket's address. |
protected abstract InputStream |
getInputStream()
Answer the socket input stream. |
protected int |
getLocalPort()
Answer the socket's localport. |
abstract Object |
getOption(int optID)
Answer the nominated socket option. |
protected abstract OutputStream |
getOutputStream()
Answer the socket output stream. |
protected int |
getPort()
Answer the socket's remote port. |
protected abstract void |
listen(int backlog)
Listen for connection requests on this stream socket. |
(package private) int |
read(byte[] buffer,
int offset,
int count)
In the IP stack, read at most count bytes off the socket
into the buffer, at the offset. |
protected abstract void |
sendUrgentData(int value)
Send the single byte of urgent data on the socket. |
abstract void |
setOption(int optID,
Object val)
Set the nominated socket option. |
protected void |
setPerformancePreferences(int connectionTime,
int latency,
int bandwidth)
Sets performance preference for connectionTime, latency and bandwidth. |
protected void |
shutdownInput()
Shutdown the input portion of the socket. |
protected void |
shutdownOutput()
Shutdown the output portion of the socket. |
protected boolean |
supportsUrgentData()
Answer if the socket supports urgent data. |
String |
toString()
Returns a string containing a concise, human-readable description of the socket. |
(package private) int |
write(byte[] buffer,
int offset,
int count)
In the IP stack, write at most count bytes on the socket
from the buffer, from the offset. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected InetAddress address
protected int port
protected FileDescriptor fd
protected int localport
org.apache.harmony.luni.platform.INetworkSystem netImpl
protected int receiveTimeout
boolean streaming
boolean shutdownInput
| Constructor Detail |
|---|
public SocketImpl()
SocketImplFactory| Method Detail |
|---|
protected abstract void accept(SocketImpl newSocket)
throws IOException
newSocket - the socket to accept connections on
SocketException - if an error occurs while accepting
IOException
protected abstract int available()
throws IOException
SocketException - if an error occurs while peeking
IOException
protected abstract void bind(InetAddress address,
int port)
throws IOException
address - the local machine address to bind the socket toport - the port on the local machine to bind the socket to
IOException - if an error occurs while binding
protected abstract void close()
throws IOException
IOException - if an error occurs while closing
protected abstract void connect(String host,
int port)
throws IOException
host - the remote host to connect toport - the remote port to connect to
IOException - if an error occurs while connecting
protected abstract void connect(InetAddress address,
int port)
throws IOException
address - the remote host address to connect toport - the remote port to connect to
IOException - if an error occurs while connecting
protected abstract void create(boolean isStreaming)
throws IOException
isStreaming - true, if the socket is type streaming
SocketException - if an error occurs while creating the socket
IOExceptionprotected FileDescriptor getFileDescriptor()
protected InetAddress getInetAddress()
protected abstract InputStream getInputStream()
throws IOException
IOException - thrown if an error occurs while accessing the streamprotected int getLocalPort()
public abstract Object getOption(int optID)
throws SocketException
getOption in interface SocketOptionsoptID - the socket option to retrieve
SocketException - thrown if an error occurs while accessing the option
protected abstract OutputStream getOutputStream()
throws IOException
IOException - thrown if an error occurs while accessing the streamprotected int getPort()
protected abstract void listen(int backlog)
throws IOException
backlog - the max number of outstanding connection requests
IOException - thrown if an error occurs while listening
int read(byte[] buffer,
int offset,
int count)
throws IOException
count bytes off the socket
into the buffer, at the offset. If the
timeout is zero, block indefinitely waiting for data, otherwise wait the
specified period (in milliseconds).
buffer - the buffer to read intooffset - the offset into the buffercount - the max number of bytes to read
IOException - thrown if an error occurs while reading
public abstract void setOption(int optID,
Object val)
throws SocketException
setOption in interface SocketOptionsoptID - the socket option to setval - the option value
SocketException - thrown if an error occurs while setting the optionpublic String toString()
toString in class Object
int write(byte[] buffer,
int offset,
int count)
throws IOException
count bytes on the socket
from the buffer, from the offset.
buffer - the buffer to read intooffset - the offset into the buffercount - the number of bytes to write
IOException - thrown if an error occurs while writing
protected void shutdownInput()
throws IOException
IOException
to indicate that the subclass should have overridden this
method.
IOException - Always. Designed to be subclassed.
protected void shutdownOutput()
throws IOException
IOException
to indicate that the subclass should have overridden this
method.
IOException - Always. Designed to be subclassed.
protected abstract void connect(SocketAddress remoteAddr,
int timeout)
throws IOException
remoteAddr - the remote machine address and port to connect totimeout - the millisecond timeout value, the connect will block
indefinitely for a zero value.
IOException - if a problem occurs during the connectprotected boolean supportsUrgentData()
protected abstract void sendUrgentData(int value)
throws IOException
value - the byte of urgent data
IOException - when an error occurs sending urgent data
protected void setPerformancePreferences(int connectionTime,
int latency,
int bandwidth)
connectionTime - the importance of connect timelatency - the importance of latencybandwidth - the importance of bandwidth
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||