public class OncRpcTcpSocketHelper extends Object
Sun always toutes Java as the perfect network "whatever" (replace with buzzword-of-the-day, like "programming language", "operating system",...) and especially their support for the Web. Sweet irony that it took them until JRE 1.3 to realize that half-closed connections are the way to do HTTP/1.0 non-persistent connections. And even more irony that they are now beginning to understand about polled network i/o.
The following JRE-dependent methods are wrapped and will just do nothing or return fake information on old JRE plattforms. The number after each method wrapper indicates the first JRE version supporting a particular feature:
The following methods have been around since JDK 1.1, so we do not need to wrap them as we will never support JDK 1.0 -- let it rest in piece(s):
In order to support connect() timeouts before JDK 1.4, there's
now a connect()
method available. It is more than just a
simple wrapper for pre JDK 1.4.
Constructor and Description |
---|
OncRpcTcpSocketHelper()
Creates a stream socket helper but does not associates it with
a real stream socket object.
|
OncRpcTcpSocketHelper(Socket socket)
Creates a stream socket helper and associates it with the given
stream-based socket.
|
Modifier and Type | Method and Description |
---|---|
Socket |
connect(InetAddress address,
int port,
int timeout)
Connects to specified TCP port at given host address, but aborts
after timeout milliseconds if the connection could not be established
within this time frame.
|
int |
getReceiveBufferSize()
Get size of receive buffer for this socket.
|
int |
getSendBufferSize()
Get size of send buffer for this socket.
|
protected void |
inspectSocketClassMethods()
Looks up methods of class Socket whether they are supported by the
class libraries of the JRE we are currently executing on.
|
void |
setReceiveBufferSize(int size)
Sets the socket's receive buffer size as a hint to the underlying
transport layer to use appropriately sized I/O buffers.
|
void |
setSendBufferSize(int size)
Sets the socket's send buffer size as a hint to the underlying
transport layer to use appropriately sized I/O buffers.
|
public OncRpcTcpSocketHelper(Socket socket)
socket
- The socket associated with this helper.public OncRpcTcpSocketHelper()
connect(java.net.InetAddress, int, int)
lateron for a timeout-controlled connect.public Socket connect(InetAddress address, int port, int timeout) throws IOException
On pre-JRE 1.4 systems, this method will create a new thread to handle connection establishment. This should be no problem, as in general you might not want to connect to many ONC/RPC servers at the same time; but surely someone will soon pop up with a perfect reason just to do so...
address
- The Java internet address representation of the remote
host to connect to.port
- The port number at the remote host to connect to.timeout
- Timeout in milliseconds for connection operation.
A negative timeout leaves the exact timeout up to the particular
JVM and java.net implementation.IOException
- with the message "connect interrupted" in case the
timeout was reached before the connection could be established.public void setSendBufferSize(int size) throws SocketException
size
- The size to which to set the send buffer size. This value
must be greater than 0.SocketException
- if the socket's send buffer size could not
be set, because the transport layer decided against accepting the
new buffer size.IllegalArgumentException
- if size
is 0 or negative.public int getSendBufferSize() throws SocketException
SocketException
- If the transport layer could not be queried
for the size of this socket's send buffer.public void setReceiveBufferSize(int size) throws SocketException
size
- The size to which to set the receive buffer size. This value
must be greater than 0.SocketException
- if the socket's receive buffer size could not
be set, because the transport layer decided against accepting the
new buffer size.IllegalArgumentException
- if size
is 0 or negative.public int getReceiveBufferSize() throws SocketException
SocketException
- If the transport layer could not be queried
for the size of this socket's receive buffer.protected void inspectSocketClassMethods()
Copyright © 2022. All rights reserved.