Methods Summary |
---|
protected abstract void | accept(java.net.SocketImpl newSocket)Waits for an incoming request and blocks until the connection is opened
on the given socket.
|
protected abstract int | available()Returns the available number of bytes which are readable from this socket
without blocking.
|
protected abstract void | bind(java.net.InetAddress address, int port)Binds this socket to the specified local host address and port number.
|
protected abstract void | close()Closes this socket. This makes later access invalid.
|
protected abstract void | connect(java.net.SocketAddress remoteAddr, int timeout)Connects this socket to the remote host address and port number specified
by the {@code SocketAddress} object with the given timeout. This method
will block indefinitely if the timeout is set to zero.
|
protected abstract void | connect(java.lang.String host, int port)Connects this socket to the specified remote host and port number.
|
protected abstract void | connect(java.net.InetAddress address, int port)Connects this socket to the specified remote host address and port
number.
|
protected abstract void | create(boolean isStreaming)Creates a new unconnected socket. The argument {@code isStreaming}
defines whether the new socket is a streaming or a datagram socket.
|
protected java.io.FileDescriptor | getFileDescriptor()Gets the file descriptor of this socket.
return fd;
|
protected java.net.InetAddress | getInetAddress()Gets the remote address this socket is connected to.
return address;
|
protected abstract java.io.InputStream | getInputStream()Gets the input stream of this socket.
|
protected int | getLocalPort()Gets the local port number of this socket. The field is initialized to
{@code -1} and upon demand will go to the IP stack to get the bound
value. See the class comment for the context of the local port.
return localport;
|
public abstract java.lang.Object | getOption(int optID)Gets the value of the given socket option.
|
protected abstract java.io.OutputStream | getOutputStream()Gets the output stream of this socket.
|
protected int | getPort()Gets the remote port number of this socket. This value is not meaningful
when this instance is wrapped by a {@code ServerSocket}.
return port;
|
protected abstract void | listen(int backlog)Listens for connection requests on this streaming socket. Incoming
connection requests are queued up to the limit specified by {@code
backlog}. Additional requests are rejected. The method {@code listen()}
may only be invoked on streaming sockets.
|
int | read(byte[] buffer, int offset, int count)In the IP stack, read at most {@code count} bytes off the socket
into the {@code buffer}, at the {@code offset}. If the timeout
is zero, block indefinitely waiting for data, otherwise wait the
specified period (in milliseconds).
if (shutdownInput) {
return -1;
}
try {
// BEGIN android-added
int receiveTimeout = (Integer)getOption(SocketOptions.SO_TIMEOUT);
// END android-added
int read = this.netImpl.receiveStream(fd, buffer, offset, count,
receiveTimeout);
if (read == -1) {
shutdownInput = true;
}
return read;
} catch (InterruptedIOException e) {
throw new SocketTimeoutException(e.getMessage());
}
|
protected abstract void | sendUrgentData(int value)Sends the single byte of urgent data on the socket.
|
public abstract void | setOption(int optID, java.lang.Object val)Sets the value for the specified socket option.
|
protected void | setPerformancePreferences(int connectionTime, int latency, int bandwidth)Sets performance preference for connection time, latency and bandwidth.
Does nothing by default.
// Our socket implementation only provide one protocol: TCP/IP, so
// we do nothing for this method
|
protected void | shutdownInput()Closes the input channel of this socket.
This default implementation always throws an {@link IOException} to
indicate that the subclass should have overridden this method.
// KA025=Method has not been implemented
throw new IOException(Msg.getString("KA025"));//$NON-NLS-1$
|
protected void | shutdownOutput()Closes the output channel of this socket.
This default implementation always throws an {@link IOException} to
indicate that the subclass should have overridden this method.
// KA025=Method has not been implemented
throw new IOException(Msg.getString("KA025"));//$NON-NLS-1$
|
protected boolean | supportsUrgentData()Returns whether the socket supports urgent data or not. Subclasses should
override this method.
return false;
|
public java.lang.String | toString()Returns a string containing a concise, human-readable description of the
socket.
return new StringBuffer(100).append("Socket[addr=").append(
getInetAddress()).append(",port=").append(port).append(
",localport=").append(getLocalPort()).append("]").toString();
|
int | write(byte[] buffer, int offset, int count)In the IP stack, write at most {@code count} bytes on the socket
from the {@code buffer}, from the {@code offset}.
if (!streaming) {
// BEGIN android-changed
// copied from newer harmony version
return this.netImpl
.sendDatagram2(fd, buffer, offset, count, port, address);
// END android-changed
}
return this.netImpl.sendStream(fd, buffer, offset, count);
|