/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#include <windows.h>
#include <winsock2.h>
#include "jni.h"
#include "net_util.h"
#include "java_net_DualStackPlainSocketImpl.h"
#define SET_BLOCKING 0
/*
* Class: java_net_DualStackPlainSocketImpl
* Method: initIDs
* Signature: ()V
*/
"(Ljava/net/InetAddress;I)V");
// implement read timeout with select.
}
/*
* Class: java_net_DualStackPlainSocketImpl
* Method: socket0
* Signature: (ZZ)I
*/
if (fd == INVALID_SOCKET) {
return -1;
}
if (rv == SOCKET_ERROR) {
}
return fd;
}
/*
* Class: java_net_DualStackPlainSocketImpl
* Method: bind0
* Signature: (ILjava/net/InetAddress;I)V
*/
{
int rv;
return;
}
if (rv == SOCKET_ERROR)
}
/*
* Class: java_net_DualStackPlainSocketImpl
* Method: connect0
* Signature: (ILjava/net/InetAddress;I)I
*/
int rv;
return -1;
}
if (rv == SOCKET_ERROR) {
if (err == WSAEWOULDBLOCK) {
} else if (err == WSAEADDRNOTAVAIL) {
"connect: Address is invalid on local machine, or port is not valid on remote machine");
} else {
}
return -1; // return value not important.
}
return rv;
}
/*
* Class: java_net_DualStackPlainSocketImpl
* Method: waitForConnect
* Signature: (II)V
*/
struct timeval t;
/*
* Wait for timeout, connection established or
* connection failed.
*/
/*
* Timeout before connection is established/failed so
* socket from being used.
* The socket should be closed immediately by the caller.
*/
if (rv == 0) {
"connect timed out");
return;
}
/*
* Socket is writable or error occured. On some Windows editions
* the socket will appear writable when the connect fails so we
* check for error rather than writable.
*/
return; /* connection established */
}
/*
* Connection failed. The logic here is designed to work around
* bug on Windows NT whereby using getsockopt to obtain the
* last error (SO_ERROR) indicates there is no error. The workaround
* on NT is to allow winsock to be scheduled and this is done by
* yielding and retrying. As yielding is problematic in heavy
* load conditions we attempt up to 3 times to get the error reason.
*/
if (rv) {
break;
}
Sleep(0);
}
if (rv == 0) {
"Unable to establish connection");
} else {
}
}
/*
* Class: java_net_DualStackPlainSocketImpl
* Method: localPort0
* Signature: (I)I
*/
if (WSAGetLastError() == WSAENOTSOCK) {
"Socket closed");
} else {
}
return -1;
}
}
/*
* Class: java_net_DualStackPlainSocketImpl
* Method: localAddress
* Signature: (ILjava/net/InetAddressContainer;)V
*/
int port;
return;
}
}
/*
* Class: java_net_DualStackPlainSocketImpl
* Method: listen0
* Signature: (II)V
*/
}
}
/*
* Class: java_net_DualStackPlainSocketImpl
* Method: accept0
* Signature: (I[Ljava/net/InetSocketAddress;)I
*/
if (newfd == INVALID_SOCKET) {
if (WSAGetLastError() == -2) {
"operation interrupted");
} else {
"socket closed");
}
return -1;
}
return newfd;
}
/*
* Class: java_net_DualStackPlainSocketImpl
* Method: waitForNewConnection
* Signature: (II)V
*/
int rv;
if (rv == 0) {
"Accept timed out");
} else if (rv == -1) {
} else if (rv == -2) {
"operation interrupted");
}
}
/*
* Class: java_net_DualStackPlainSocketImpl
* Method: available0
* Signature: (I)I
*/
}
return available;
}
/*
* Class: java_net_DualStackPlainSocketImpl
* Method: close0
* Signature: (I)V
*/
}
/*
* Class: java_net_DualStackPlainSocketImpl
* Method: shutdown0
* Signature: (II)V
*/
}
/*
* Class: java_net_DualStackPlainSocketImpl
* Method: setIntOption
* Signature: (III)V
*/
char *parg;
int arglen;
JNU_JAVANETPKG "SocketException",
"Invalid option");
return;
}
if (opt == java_net_SocketOptions_SO_LINGER) {
if (value >= 0) {
} else {
}
} else {
}
}
}
/*
* Class: java_net_DualStackPlainSocketImpl
* Method: getIntOption
* Signature: (II)I
*/
int result=0;
char *arg;
int arglen;
JNU_JAVANETPKG "SocketException",
"Unsupported socket option");
return -1;
}
if (opt == java_net_SocketOptions_SO_LINGER) {
} else {
}
return -1;
}
if (opt == java_net_SocketOptions_SO_LINGER)
else
return result;
}
/*
* Class: java_net_DualStackPlainSocketImpl
* Method: sendOOB
* Signature: (II)V
*/
jint n;
unsigned char d = (unsigned char) data & 0xff;
if (n == JVM_IO_ERR) {
} else if (n == JVM_IO_INTR) {
}
}
/*
* Class: java_net_DualStackPlainSocketImpl
* Method: configureBlocking
* Signature: (IZ)V
*/
int result;
} else {
}
if (result == SOCKET_ERROR) {
}
}