37 |
|
|
38 |
package java.net; |
package java.net; |
39 |
|
|
40 |
import java.io.*; |
import java.io.InputStream; |
41 |
|
import java.io.IOException; |
42 |
|
import java.io.OutputStream; |
43 |
import java.nio.channels.SocketChannel; |
import java.nio.channels.SocketChannel; |
44 |
import java.nio.channels.IllegalBlockingModeException; |
import java.nio.channels.IllegalBlockingModeException; |
45 |
|
|
89 |
|
|
90 |
private boolean closed = false; |
private boolean closed = false; |
91 |
|
|
|
// Constructors |
|
|
|
|
92 |
/** |
/** |
93 |
* Initializes a new instance of <code>Socket</code> object without |
* Initializes a new instance of <code>Socket</code> object without |
94 |
* connecting to a remote host. This useful for subclasses of socket that |
* connecting to a remote host. This useful for subclasses of socket that |
282 |
{ |
{ |
283 |
this(); |
this(); |
284 |
|
|
285 |
|
if (raddr == null) |
286 |
|
throw new NullPointerException (); |
287 |
|
|
288 |
if (impl == null) |
if (impl == null) |
289 |
throw new IOException("Cannot initialize Socket implementation"); |
throw new IOException("Cannot initialize Socket implementation"); |
290 |
|
|
292 |
if (sm != null) |
if (sm != null) |
293 |
sm.checkConnect(raddr.getHostName(), rport); |
sm.checkConnect(raddr.getHostName(), rport); |
294 |
|
|
295 |
// bind/connect socket |
// bind socket |
296 |
bind (new InetSocketAddress (laddr, lport)); |
SocketAddress bindaddr = |
297 |
|
laddr == null ? null : new InetSocketAddress (laddr, lport); |
298 |
|
bind (bindaddr); |
299 |
|
|
300 |
|
// connect socket |
301 |
connect (new InetSocketAddress (raddr, rport)); |
connect (new InetSocketAddress (raddr, rport)); |
302 |
|
|
303 |
// FIXME: JCL p. 1586 says if localPort is unspecified, bind to any port, |
// FIXME: JCL p. 1586 says if localPort is unspecified, bind to any port, |