Methods Summary |
---|
public void | associate(java.net.InetAddress address, int port)Associates with a remote host. This defines the destination of the
outgoing packets.
if (isBusy()) {
throw new IllegalStateException("Busy");
}
if (!(address instanceof Inet4Address && mLocalAddress instanceof Inet4Address) &&
!(address instanceof Inet6Address && mLocalAddress instanceof Inet6Address)) {
throw new IllegalArgumentException("Unsupported address");
}
if (port < 0 || port > 65535) {
throw new IllegalArgumentException("Invalid port");
}
mRemoteAddress = address;
mRemotePort = port;
|
private native void | close()
|
private native int | create(java.lang.String address)
|
protected void | finalize()
close();
super.finalize();
|
public java.net.InetAddress | getLocalAddress()Returns the network address of the local host.
return mLocalAddress;
|
public int | getLocalPort()Returns the network port of the local host.
return mLocalPort;
|
public int | getMode()Returns the current mode.
return mMode;
|
public java.net.InetAddress | getRemoteAddress()Returns the network address of the remote host or {@code null} if the
stream is not associated.
return mRemoteAddress;
|
public int | getRemotePort()Returns the network port of the remote host or {@code -1} if the stream
is not associated.
return mRemotePort;
|
int | getSocket()
return mSocket;
|
public boolean | isBusy()Returns {@code true} if the stream is busy. In this case most of the
setter methods are disabled. This method is intended to be overridden
by subclasses.
return false;
|
public void | release()Releases allocated resources. The stream becomes inoperable after calling
this method.
synchronized (this) {
if (isBusy()) {
throw new IllegalStateException("Busy");
}
close();
}
|
public void | setMode(int mode)Changes the current mode. It must be one of {@link #MODE_NORMAL},
{@link #MODE_SEND_ONLY}, and {@link #MODE_RECEIVE_ONLY}.
if (isBusy()) {
throw new IllegalStateException("Busy");
}
if (mode < 0 || mode > MODE_LAST) {
throw new IllegalArgumentException("Invalid mode");
}
mMode = mode;
|