Methods Summary |
---|
protected static native int | available0(int handle)
|
public synchronized void | close()Close the connection.
if (copen) {
copen = false;
realClose();
}
|
protected static native void | close0(int handle)
|
void | ensureOpen()Ensure connection is open
if (!copen) {
throw new IOException(
/* #ifdef VERBOSE_EXCEPTIONS */
/// skipped "Connection closed"
/* #endif */
);
}
|
public void | open(java.lang.String name, int mode, boolean timeouts)Open the connection
throw new RuntimeException(
/* #ifdef VERBOSE_EXCEPTIONS */
/// skipped "Should not be called"
/* #endif */
);
|
public void | open(int handle, int mode)Open the connection
this.handle = handle;
opens++;
copen = true;
this.mode = mode;
|
protected static native int | open0(byte[] hostname, int port, int mode)
|
public java.io.DataInputStream | openDataInputStream()Open and return a data input stream for a connection.
return new DataInputStream(openInputStream());
|
public java.io.DataOutputStream | openDataOutputStream()Open and return a data output stream for a connection.
return new DataOutputStream(openOutputStream());
|
public synchronized java.io.InputStream | openInputStream()Returns an input stream for this socket.
ensureOpen();
if ((mode&Connector.READ) == 0) {
throw new IOException(
/* #ifdef VERBOSE_EXCEPTIONS */
/// skipped "Connection not open for reading"
/* #endif */
);
}
if (isopen) {
throw new IOException(
/* #ifdef VERBOSE_EXCEPTIONS */
/// skipped "Input stream already opened"
/* #endif */
);
}
isopen = true;
InputStream in = new PrivateInputStream(this);
opens++;
return in;
|
public synchronized java.io.OutputStream | openOutputStream()Returns an output stream for this socket.
ensureOpen();
if ((mode&Connector.WRITE) == 0) {
throw new IOException(
/* #ifdef VERBOSE_EXCEPTIONS */
/// skipped "Connection not open for writing"
/* #endif */
);
}
if (osopen) {
throw new IOException(
/* #ifdef VERBOSE_EXCEPTIONS */
/// skipped "Output stream already opened"
/* #endif */
);
}
osopen = true;
OutputStream os = new PrivateOutputStream(this);
opens++;
return os;
|
public Connection | openPrim(java.lang.String name, int mode, boolean timeouts)Open the connection
if (!name.startsWith("//")) {
throw new IOException(
/* #ifdef VERBOSE_EXCEPTIONS */
/// skipped "bad socket connection name: " + name
/* #endif */
);
}
int i = name.indexOf(':");
if (i < 0) {
throw new IOException(
/* #ifdef VERBOSE_EXCEPTIONS */
/// skipped "bad socket connection name: port missing"
/* #endif */
);
}
String hostname = name.substring(2, i);
int port;
try {
port = Integer.parseInt(name.substring(i+1));
} catch (NumberFormatException e) {
throw new IOException(
/* #ifdef VERBOSE_EXCEPTIONS */
/// skipped "bad socket connection name: bad port"
/* #endif */
);
}
// cstring is always NUL terminated (note the extra byte allocated).
// This avoids awkward char array manipulation in C code.
byte cstring[] = new byte[hostname.length() + 1];
for (int n=0; n<hostname.length(); n++) {
cstring[n] = (byte)(hostname.charAt(n));
}
if ((this.handle = open0(cstring, port, mode)) < 0) {
int errorCode = this.handle & 0x7fffffff;
throw new IOException(
/* #ifdef VERBOSE_EXCEPTIONS */
/// skipped "connection failed: error = " + errorCode
/* #endif */
);
}
opens++;
copen = true;
this.mode = mode;
return this;
|
protected static native int | readBuf(int handle, byte[] b, int off, int len)
|
protected static native int | readByte(int handle)
|
synchronized void | realClose()Close the connection.
if (--opens == 0) {
close0(this.handle);
}
|
protected static native int | writeBuf(int handle, byte[] b, int off, int len)
|
protected static native int | writeByte(int handle, int b)
|