63 |
{ |
{ |
64 |
// Static initializer to load native library. |
// Static initializer to load native library. |
65 |
static |
static |
66 |
{ |
{ |
67 |
if (Configuration.INIT_LOAD_LIBRARY) |
if (Configuration.INIT_LOAD_LIBRARY) |
68 |
{ |
{ |
69 |
System.loadLibrary("javanet"); |
System.loadLibrary("javanet"); |
70 |
} |
} |
71 |
} |
} |
72 |
|
|
73 |
/** |
/** |
74 |
* The OS file handle representing the socket. |
* The OS file handle representing the socket. |
80 |
protected int native_fd = -1; |
protected int native_fd = -1; |
81 |
|
|
82 |
/** |
/** |
83 |
|
* A cached copy of the in stream for reading from the socket. |
84 |
|
*/ |
85 |
|
private InputStream in; |
86 |
|
|
87 |
|
/** |
88 |
|
* A cached copy of the out stream for writing to the socket. |
89 |
|
*/ |
90 |
|
private OutputStream out; |
91 |
|
|
92 |
|
/** |
93 |
* Default do nothing constructor |
* Default do nothing constructor |
94 |
*/ |
*/ |
95 |
public PlainSocketImpl() |
public PlainSocketImpl() |
107 |
* |
* |
108 |
* @exception SocketException If an error occurs |
* @exception SocketException If an error occurs |
109 |
*/ |
*/ |
110 |
public native void setOption(int option_id, Object val) |
public native void setOption(int optID, Object value) throws SocketException; |
|
throws SocketException; |
|
111 |
|
|
112 |
/** |
/** |
113 |
* Returns the current setting of the specified option. The Object returned |
* Returns the current setting of the specified option. The Object returned |
120 |
* |
* |
121 |
* @exception SocketException If an error occurs |
* @exception SocketException If an error occurs |
122 |
*/ |
*/ |
123 |
public native Object getOption(int option_id) |
public native Object getOption(int optID) throws SocketException; |
|
throws SocketException; |
|
124 |
|
|
125 |
public void shutdownInput() |
public void shutdownInput() |
126 |
{ |
{ |
151 |
* |
* |
152 |
* @exception IOException If an error occurs |
* @exception IOException If an error occurs |
153 |
*/ |
*/ |
154 |
protected synchronized void connect(String hostname, int port) |
protected synchronized void connect (String host, int port) throws IOException |
|
throws IOException |
|
155 |
{ |
{ |
156 |
InetAddress addr = InetAddress.getByName(hostname); |
connect (InetAddress.getByName (host), port); |
|
connect(addr, port); |
|
157 |
} |
} |
158 |
|
|
159 |
/** |
/** |
167 |
protected native void connect(InetAddress addr, int port) |
protected native void connect(InetAddress addr, int port) |
168 |
throws IOException; |
throws IOException; |
169 |
|
|
170 |
public void connect(SocketAddress address, int timeout) |
protected void connect(SocketAddress address, int timeout) |
171 |
{ |
{ |
172 |
throw new InternalError ("PlainSocketImpl::connect not implemented"); |
throw new InternalError ("PlainSocketImpl::connect not implemented"); |
173 |
} |
} |
264 |
*/ |
*/ |
265 |
protected synchronized InputStream getInputStream() throws IOException |
protected synchronized InputStream getInputStream() throws IOException |
266 |
{ |
{ |
267 |
return(new SocketInputStream(this)); |
if (in == null) |
268 |
|
in = new SocketInputStream (this); |
269 |
|
|
270 |
|
return in; |
271 |
} |
} |
272 |
|
|
273 |
/** |
/** |
280 |
*/ |
*/ |
281 |
protected synchronized OutputStream getOutputStream() throws IOException |
protected synchronized OutputStream getOutputStream() throws IOException |
282 |
{ |
{ |
283 |
return(new SocketOutputStream(this)); |
if (out == null) |
284 |
|
out = new SocketOutputStream (this); |
285 |
|
|
286 |
|
return out; |
287 |
} |
} |
288 |
} |
} |