Path: blob/master/src/java.base/windows/native/libnio/ch/nio_util.h
41134 views
/*1* Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425#include <winsock2.h>26#include <ws2tcpip.h>27#include <afunix.h>2829#include "jni.h"3031/**32* The maximum buffer size for WSASend/WSARecv. Microsoft recommendation for33* blocking operations is to use buffers no larger than 64k. We need the34* maximum to be less than 128k to support asynchronous close on Windows35* Server 2003 and newer editions of Windows.36*/37#define MAX_BUFFER_SIZE ((128*1024)-1)3839#define MAX_UNIX_DOMAIN_PATH_LEN \40(int)(sizeof(((struct sockaddr_un *)0)->sun_path)-2)4142jint fdval(JNIEnv *env, jobject fdo);43void setfdval(JNIEnv *env, jobject fdo, jint val);44jlong handleval(JNIEnv *env, jobject fdo);45jint convertReturnVal(JNIEnv *env, jint n, jboolean r);46jlong convertLongReturnVal(JNIEnv *env, jlong n, jboolean r);47jboolean purgeOutstandingICMP(JNIEnv *env, jclass clazz, jint fd);48jint handleSocketError(JNIEnv *env, int errorValue);4950#ifdef _WIN645152struct iovec {53jlong iov_base;54jint iov_len;55};5657#else5859struct iovec {60jint iov_base;61jint iov_len;62};6364#endif6566/* Defined in UnixDomainSockets.c */6768jbyteArray sockaddrToUnixAddressBytes(JNIEnv *env, struct sockaddr_un *sa, socklen_t len);6970jint unixSocketAddressToSockaddr(JNIEnv *env, jbyteArray uaddr,71struct sockaddr_un *sa, int *len);72737475