/*
* 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 <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include "java_net_SocketInputStream.h"
#include "net_util.h"
#include "jni_util.h"
/*************************************************************************
* SocketInputStream
*/
/*
* Class: java_net_SocketInputStream
* Method: init
* Signature: ()V
*/
}
/*
* Class: java_net_SocketInputStream
* Method: socketRead
* Signature: (Ljava/io/FileDescriptor;[BIII)I
*/
{
char *bufP;
return -1;
}
if (fd == -1) {
return -1;
}
/*
* If the caller buffer is large than our stack buffer then we allocate
* from the heap (up to a limit). If memory is exhausted we always use
* the stack buffer.
*/
if (len <= MAX_BUFFER_LEN) {
} else {
if (len > MAX_HEAP_BUFFER_LEN) {
}
/* allocation failed so use stack buffer */
}
}
if (timeout) {
if (ret <= 0) {
if (ret == 0) {
"Read timed out");
} else if (ret == JVM_IO_ERR) {
} else if (ret == JVM_IO_INTR) {
"Operation interrupted");
}
}
return -1;
}
/*check if the socket has been closed while we were in timeout*/
if (newfd == -1) {
}
return -1;
}
}
}
if (nread > 0) {
} else {
if (nread < 0) {
/*
* Recv failed.
*/
switch (WSAGetLastError()) {
case WSAEINTR:
"socket closed");
break;
case WSAECONNRESET:
case WSAESHUTDOWN:
/*
* Connection has been reset - Windows sometimes reports
* the reset as a shutdown error.
*/
"");
break;
case WSAETIMEDOUT :
"Read timed out");
break;
default:
}
}
}
}
return nread;
}