167 |
protected native void connect(InetAddress addr, int port) |
protected native void connect(InetAddress addr, int port) |
168 |
throws IOException; |
throws IOException; |
169 |
|
|
170 |
protected void connect(SocketAddress address, int timeout) |
protected synchronized void connect(SocketAddress address, int timeout) |
171 |
throws IOException |
throws IOException |
172 |
{ |
{ |
173 |
// NYI: this method need to support timeout |
InetSocketAddress sockAddr = (InetSocketAddress) address; |
174 |
if (address instanceof InetSocketAddress) |
InetAddress addr = sockAddr.getAddress(); |
175 |
|
|
176 |
|
if (addr == null) |
177 |
|
throw new IllegalArgumentException ("address is unresolved: " + sockAddr); |
178 |
|
|
179 |
|
int port = sockAddr.getPort(); |
180 |
|
|
181 |
|
if (timeout < 0) |
182 |
|
throw new IllegalArgumentException ("negative timeout"); |
183 |
|
|
184 |
|
Object oldTimeoutObj = null; |
185 |
|
|
186 |
|
try |
187 |
{ |
{ |
188 |
connect(((InetSocketAddress) address).getAddress(), |
oldTimeoutObj = this.getOption (SocketOptions.SO_TIMEOUT); |
189 |
((InetSocketAddress) address).getPort() ); |
this.setOption (SocketOptions.SO_TIMEOUT, new Integer (timeout)); |
190 |
|
connect (addr, port); |
191 |
} |
} |
192 |
else |
finally |
193 |
{ |
{ |
194 |
throw new InternalError("PlainSocketImpl:connect not implemented for anything other than InetSocketAddress"); |
if (oldTimeoutObj != null) |
195 |
|
this.setOption (SocketOptions.SO_TIMEOUT, oldTimeoutObj); |
196 |
} |
} |
|
// throw new InternalError ("PlainSocketImpl::connect not implemented"); |
|
197 |
} |
} |
198 |
|
|
199 |
/** |
/** |