equal
deleted
inserted
replaced
31 import java.io.InterruptedIOException; |
31 import java.io.InterruptedIOException; |
32 import java.io.FileDescriptor; |
32 import java.io.FileDescriptor; |
33 import java.io.ByteArrayOutputStream; |
33 import java.io.ByteArrayOutputStream; |
34 |
34 |
35 import sun.net.ConnectionResetException; |
35 import sun.net.ConnectionResetException; |
|
36 import sun.net.NetHooks; |
36 |
37 |
37 /** |
38 /** |
38 * Default Socket Implementation. This implementation does |
39 * Default Socket Implementation. This implementation does |
39 * not implement any security checks. |
40 * not implement any security checks. |
40 * Note this class should <b>NOT</b> be public. |
41 * Note this class should <b>NOT</b> be public. |
302 * establish a connection to the given <host, port>. If unsuccessful, |
303 * establish a connection to the given <host, port>. If unsuccessful, |
303 * throws an IOException indicating what went wrong. |
304 * throws an IOException indicating what went wrong. |
304 */ |
305 */ |
305 |
306 |
306 synchronized void doConnect(InetAddress address, int port, int timeout) throws IOException { |
307 synchronized void doConnect(InetAddress address, int port, int timeout) throws IOException { |
|
308 synchronized (fdLock) { |
|
309 if (!closePending && (socket == null || !socket.isBound())) { |
|
310 NetHooks.beforeTcpConnect(fd, address, port); |
|
311 } |
|
312 } |
307 try { |
313 try { |
308 FileDescriptor fd = acquireFD(); |
314 FileDescriptor fd = acquireFD(); |
309 try { |
315 try { |
310 socketConnect(address, port, timeout); |
316 socketConnect(address, port, timeout); |
311 /* socket may have been closed during poll/select */ |
317 /* socket may have been closed during poll/select */ |
337 * @param port the port |
343 * @param port the port |
338 */ |
344 */ |
339 protected synchronized void bind(InetAddress address, int lport) |
345 protected synchronized void bind(InetAddress address, int lport) |
340 throws IOException |
346 throws IOException |
341 { |
347 { |
|
348 synchronized (fdLock) { |
|
349 if (!closePending && (socket == null || !socket.isBound())) { |
|
350 NetHooks.beforeTcpBind(fd, address, lport); |
|
351 } |
|
352 } |
342 socketBind(address, lport); |
353 socketBind(address, lport); |
343 if (socket != null) |
354 if (socket != null) |
344 socket.setBound(); |
355 socket.setBound(); |
345 if (serverSocket != null) |
356 if (serverSocket != null) |
346 serverSocket.setBound(); |
357 serverSocket.setBound(); |