2362N/A * Copyright (c) 1998, 2008, 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 0N/A * The Socket Transport Library. 0N/A * This module is an implementation of the Java Debug Wire Protocol Transport 0N/A * Record the last error for this thread. 0N/A /* get any I/O first in case any system calls override errno */ 0N/A * Return the last error for this thread (may be NULL) 1611N/A * We should really use snprintf here but it's not available on Windows. 1611N/A * We can't use jio_snprintf without linking the transport against the VM. 0N/A /* check for host:port or port */ 0N/A * First see if the host is a literal IP address. 0N/A * If not then try to resolve it. 0N/A /* don't use RETURN_IO_ERROR as unknown host is normal */ 0N/A /* lookup was successful */ 0N/A /* no address provided */ 0N/A * Use a default handshake timeout if not specified - this avoids an indefinite 0N/A * hang in cases where something other than a debugger connects to our port. 0N/A * If there is an accept timeout then we put the socket in non-blocking 0N/A * mode and poll for a connection. 0N/A /* set the last error here as could be overridden by configureBlocking */ 0N/A /* restore blocking state */ 0N/A * Accept the connection 0N/A /* set the last error here as could be overridden by configureBlocking */ 0N/A * Restore the blocking state - note that the accepted socket may be in 0N/A * blocking or non-blocking mode (platform dependent). However as there 0N/A * is a handshake timeout set then it will go into non-blocking mode 0N/A * anyway for the handshake. 0N/A /* handshake with the debugger */ 0N/A * If the handshake fails then close the connection. If there if an accept 0N/A * timeout then we must adjust the timeout for the next poll. 0N/A "timeout waiting for debugger to connect");
0N/A * To do a timed connect we make the socket non-blocking 0N/A * and poll with a timeout; 0N/A * close failed - it's pointless to restore socketFD here because 0N/A * any subsequent close will likely fail aswell. 0N/A * room for header and up to MAX_DATA_SIZE data bytes 0N/A /* packet can't be null */ 0N/A /* prepare the header for transmission */ 0N/A /* Do one send for short packets, two for longer ones */ 0N/A /* Send the remaining data bytes right out of the data area. */ 0N/A break;
/* eof, return nbytes which is less than len */ 4632N/A break;
/* eof, return nbytes which is less than len */ 0N/A /* packet can't be null */ 0N/A /* read the length field */ 0N/A /* FIXME - should the error be converted to host order?? */ 0N/A * This library doesn't support multiple environments (yet) 0N/A /* initialize interface table */ 0N/A /* initialized TLS */