157 |
if (impl == null) |
if (impl == null) |
158 |
throw new IOException("Cannot initialize Socket implementation"); |
throw new IOException("Cannot initialize Socket implementation"); |
159 |
|
|
|
SecurityManager s = System.getSecurityManager(); |
|
|
if (s != null) |
|
|
s.checkListen(port); |
|
|
|
|
|
if (bindAddr == null) |
|
|
bindAddr = InetAddress.ANY_IF; |
|
|
|
|
160 |
// create socket |
// create socket |
161 |
impl.create(true); |
impl.create(true); |
162 |
|
|
163 |
// bind to address/port |
// bind/listen socket |
164 |
try |
bind (new InetSocketAddress (bindAddr, port), backlog); |
|
{ |
|
|
impl.bind(bindAddr, port); |
|
|
} |
|
|
catch (IOException exception) |
|
|
{ |
|
|
impl.close(); |
|
|
throw exception; |
|
|
} |
|
|
catch (RuntimeException exception) |
|
|
{ |
|
|
impl.close(); |
|
|
throw exception; |
|
|
} |
|
|
catch (Error error) |
|
|
{ |
|
|
impl.close(); |
|
|
throw error; |
|
|
} |
|
|
|
|
|
// listen on socket |
|
|
try |
|
|
{ |
|
|
impl.listen(backlog); |
|
|
} |
|
|
catch (IOException exception) |
|
|
{ |
|
|
impl.close(); |
|
|
throw exception; |
|
|
} |
|
|
catch (RuntimeException exception) |
|
|
{ |
|
|
impl.close(); |
|
|
throw exception; |
|
|
} |
|
|
catch (Error error) |
|
|
{ |
|
|
impl.close(); |
|
|
throw error; |
|
|
} |
|
165 |
} |
} |
166 |
|
|
167 |
/** |
/** |
212 |
if (s != null) |
if (s != null) |
213 |
s.checkListen (tmp.getPort ()); |
s.checkListen (tmp.getPort ()); |
214 |
|
|
215 |
|
// bind to address/port |
216 |
|
try |
217 |
|
{ |
218 |
impl.bind (tmp.getAddress (), tmp.getPort ()); |
impl.bind (tmp.getAddress (), tmp.getPort ()); |
219 |
|
} |
220 |
|
catch (IOException exception) |
221 |
|
{ |
222 |
|
impl.close(); |
223 |
|
throw exception; |
224 |
|
} |
225 |
|
catch (RuntimeException exception) |
226 |
|
{ |
227 |
|
impl.close(); |
228 |
|
throw exception; |
229 |
|
} |
230 |
|
catch (Error error) |
231 |
|
{ |
232 |
|
impl.close(); |
233 |
|
throw error; |
234 |
|
} |
235 |
|
|
236 |
|
// listen on socket |
237 |
|
try |
238 |
|
{ |
239 |
impl.listen(backlog); |
impl.listen(backlog); |
240 |
} |
} |
241 |
|
catch (IOException exception) |
242 |
|
{ |
243 |
|
impl.close(); |
244 |
|
throw exception; |
245 |
|
} |
246 |
|
catch (RuntimeException exception) |
247 |
|
{ |
248 |
|
impl.close(); |
249 |
|
throw exception; |
250 |
|
} |
251 |
|
catch (Error error) |
252 |
|
{ |
253 |
|
impl.close(); |
254 |
|
throw error; |
255 |
|
} |
256 |
|
} |
257 |
|
|
258 |
/** |
/** |
259 |
* This method returns the local address to which this socket is bound |
* This method returns the local address to which this socket is bound |