diff --git a/src/os/windows/vm/jvm_windows.h b/src/os/windows/vm/jvm_windows.h index a45f86c2e772a19f86aa6922101cd2dd5f20a55b..910398215589f08a05137bc8058a0446c87b841a 100644 --- a/src/os/windows/vm/jvm_windows.h +++ b/src/os/windows/vm/jvm_windows.h @@ -59,7 +59,7 @@ typedef struct _MODULEINFO { #include -typedef unsigned int socklen_t; +typedef int socklen_t; // #include "jni.h" diff --git a/src/os/windows/vm/os_windows.cpp b/src/os/windows/vm/os_windows.cpp index de38c6c12daa7c0ff8e1f989f6379f75e2c1a7ce..c607905e8364fbf9eca24c87900c64ae09b6a3f9 100644 --- a/src/os/windows/vm/os_windows.cpp +++ b/src/os/windows/vm/os_windows.cpp @@ -4820,99 +4820,92 @@ struct hostent* os::get_host_by_name(char* name) { return (struct hostent*)os::WinSock2Dll::gethostbyname(name); } - int os::socket_close(int fd) { - ShouldNotReachHere(); - return 0; + return ::closesocket(fd); } int os::socket_available(int fd, jint *pbytes) { - ShouldNotReachHere(); - return 0; + int ret = ::ioctlsocket(fd, FIONREAD, (u_long*)pbytes); + return (ret < 0) ? 0 : 1; } int os::socket(int domain, int type, int protocol) { - ShouldNotReachHere(); - return 0; + return ::socket(domain, type, protocol); } int os::listen(int fd, int count) { - ShouldNotReachHere(); - return 0; + return ::listen(fd, count); } int os::connect(int fd, struct sockaddr* him, socklen_t len) { - ShouldNotReachHere(); - return 0; + return ::connect(fd, him, len); } int os::accept(int fd, struct sockaddr* him, socklen_t* len) { - ShouldNotReachHere(); - return 0; + return ::accept(fd, him, len); } int os::sendto(int fd, char* buf, size_t len, uint flags, struct sockaddr* to, socklen_t tolen) { - ShouldNotReachHere(); - return 0; + + return ::sendto(fd, buf, (int)len, flags, to, tolen); } int os::recvfrom(int fd, char *buf, size_t nBytes, uint flags, sockaddr* from, socklen_t* fromlen) { - ShouldNotReachHere(); - return 0; + + return ::recvfrom(fd, buf, (int)nBytes, flags, from, fromlen); } int os::recv(int fd, char* buf, size_t nBytes, uint flags) { - ShouldNotReachHere(); - return 0; + return ::recv(fd, buf, (int)nBytes, flags); } int os::send(int fd, char* buf, size_t nBytes, uint flags) { - ShouldNotReachHere(); - return 0; + return ::send(fd, buf, (int)nBytes, flags); } int os::raw_send(int fd, char* buf, size_t nBytes, uint flags) { - ShouldNotReachHere(); - return 0; + return ::send(fd, buf, (int)nBytes, flags); } int os::timeout(int fd, long timeout) { - ShouldNotReachHere(); - return 0; + fd_set tbl; + struct timeval t; + + t.tv_sec = timeout / 1000; + t.tv_usec = (timeout % 1000) * 1000; + + tbl.fd_count = 1; + tbl.fd_array[0] = fd; + + return ::select(1, &tbl, 0, 0, &t); } int os::get_host_name(char* name, int namelen) { - ShouldNotReachHere(); - return 0; + return ::gethostname(name, namelen); } int os::socket_shutdown(int fd, int howto) { - ShouldNotReachHere(); - return 0; + return ::shutdown(fd, howto); } int os::bind(int fd, struct sockaddr* him, socklen_t len) { - ShouldNotReachHere(); - return 0; + return ::bind(fd, him, len); } int os::get_sock_name(int fd, struct sockaddr* him, socklen_t* len) { - ShouldNotReachHere(); - return 0; + return ::getsockname(fd, him, len); } int os::get_sock_opt(int fd, int level, int optname, char* optval, socklen_t* optlen) { - ShouldNotReachHere(); - return 0; + return ::getsockopt(fd, level, optname, optval, optlen); } int os::set_sock_opt(int fd, int level, int optname, const char* optval, socklen_t optlen) { - ShouldNotReachHere(); - return 0; + return ::setsockopt(fd, level, optname, optval, optlen); }