3909N/A * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * Default Socket Implementation. This implementation does 0N/A * not implement any security checks. 0N/A * Note this class should <b>NOT</b> be public. 0N/A * @author Steven B. Byrne 0N/A /* instance variable for SO_TIMEOUT */ 0N/A /* number of threads using the FileDescriptor */ 0N/A /* indicates a close is pending on the file descriptor */ 0N/A /* indicates connection reset state */ 3788N/A /* whether this Socket is a stream (TCP) socket or not (UDP) 0N/A * Load net library into runtime. 0N/A * Creates a socket with a boolean that specifies whether this 0N/A * is a stream socket (true) or an unconnected UDP socket (false). 4479N/A // only create the fd after we know we will be able to create the socket 0N/A * Creates a socket and connects it to the specified port on 0N/A * the specified host. 0N/A * @param host the specified host 0N/A * @param port the specified port 2986N/A /* Do nothing. If connect threw an exception then 2986N/A it will be passed up the call stack */ 0N/A * Creates a socket and connects it to the specified address on 0N/A * the specified port. 0N/A * @param address the address 0N/A * @param port the specified port 0N/A // everything failed 0N/A * Creates a socket and connects it to the specified address on 0N/A * the specified port. 0N/A * @param address the address 0N/A * @param timeout the timeout value in milliseconds, or zero for no timeout. 0N/A * @throws IOException if connection fails 0N/A * @throws IllegalArgumentException if address is null or is a 0N/A * SocketAddress subclass not supported by this socket 2986N/A /* Do nothing. If connect threw an exception then 2986N/A it will be passed up the call stack */ 0N/A /* check type safety b4 going native. These should never 0N/A * fail, since only java.Socket* has access to 0N/A * PlainSocketImpl.setOption(). 0N/A /* true only if disabling - enabling should be Integer */ 0N/A * The native socketGetOption() knows about 3 options. 0N/A * The 32 bit value it returns will be interpreted according 0N/A * to what we're asking. A return of -1 means it understands 0N/A * the option but its turned off. It will raise a SocketException 0N/A * if "opt" isn't one it understands. 0N/A // should never get here 0N/A * The workhorse of the connection operation. Tries several times to 0N/A * establish a connection to the given <host, port>. If unsuccessful, 0N/A * throws an IOException indicating what went wrong. 0N/A // If we have a ref. to the Socket, then sets the flags 0N/A // created, bound & connected to true. 0N/A // This is normally done in Socket.connect() but some 0N/A // subclasses of Socket may call impl.connect() directly! 0N/A * Binds the socket to the specified address of the specified local port. 0N/A * @param address the address 0N/A * @param port the port 0N/A * Listens, for a specified amount of time, for connections. 0N/A * @param count the amount of time to listen for connections 0N/A * Accepts connections. 0N/A * @param s the connection 0N/A * Gets an InputStream for this socket. 0N/A * Gets an OutputStream for this socket. 0N/A * Returns the number of bytes that can be read without blocking. 0N/A * If connection has been reset then return 0 to indicate 0N/A * there are no buffered bytes. 0N/A * If no bytes available and we were previously notified 0N/A * of a connection reset then we move to the reset state. 0N/A * If are notified of a connection reset then check 0N/A * again if there are bytes buffered on the socket. 0N/A * Closes the socket. 0N/A * We close the FileDescriptor in two-steps - first the 0N/A * "pre-close" which closes the socket but doesn't 0N/A * release the underlying file descriptor. This operation 0N/A * may be lengthy due to untransmitted data and a long 0N/A * linger interval. Once the pre-close is done we do the 0N/A * actual socket to release the fd. 0N/A * If a thread has acquired the fd and a close 0N/A * isn't pending then use a deferred close. 0N/A * Also decrement fdUseCount to signal the last 0N/A * thread that releases the fd to close it. 0N/A * Shutdown read-half of the socket connection; 0N/A * Shutdown write-half of the socket connection; 0N/A * Cleans up if the user forgets to close it. 0N/A * "Acquires" and returns the FileDescriptor for this impl 0N/A * A corresponding releaseFD is required to "release" the 0N/A * "Release" the FileDescriptor for this impl. 0N/A * If the use count goes to -1 then the socket is closed. 0N/A * Return true if already closed or close is pending 0N/A * Lock on fdLock to ensure that we wait if a 0N/A * close is in progress. 0N/A * Return the current value of SO_TIMEOUT 0N/A * "Pre-close" a socket by dup'ing the file descriptor - this enables 0N/A * the socket to be closed without releasing the file descriptor. 0N/A * Close the socket (and release the file descriptor).