提交 bea13805 编写于 作者: T twisti

7157695: Add windows implementation of socket interface

Reviewed-by: kvn, dholmes, twisti
Contributed-by: NNils Eliasson <nils.eliasson@oracle.com>
上级 c2d69d99
...@@ -59,7 +59,7 @@ typedef struct _MODULEINFO { ...@@ -59,7 +59,7 @@ typedef struct _MODULEINFO {
#include <Tlhelp32.h> #include <Tlhelp32.h>
typedef unsigned int socklen_t; typedef int socklen_t;
// #include "jni.h" // #include "jni.h"
......
...@@ -4820,99 +4820,92 @@ struct hostent* os::get_host_by_name(char* name) { ...@@ -4820,99 +4820,92 @@ struct hostent* os::get_host_by_name(char* name) {
return (struct hostent*)os::WinSock2Dll::gethostbyname(name); return (struct hostent*)os::WinSock2Dll::gethostbyname(name);
} }
int os::socket_close(int fd) { int os::socket_close(int fd) {
ShouldNotReachHere(); return ::closesocket(fd);
return 0;
} }
int os::socket_available(int fd, jint *pbytes) { int os::socket_available(int fd, jint *pbytes) {
ShouldNotReachHere(); int ret = ::ioctlsocket(fd, FIONREAD, (u_long*)pbytes);
return 0; return (ret < 0) ? 0 : 1;
} }
int os::socket(int domain, int type, int protocol) { int os::socket(int domain, int type, int protocol) {
ShouldNotReachHere(); return ::socket(domain, type, protocol);
return 0;
} }
int os::listen(int fd, int count) { int os::listen(int fd, int count) {
ShouldNotReachHere(); return ::listen(fd, count);
return 0;
} }
int os::connect(int fd, struct sockaddr* him, socklen_t len) { int os::connect(int fd, struct sockaddr* him, socklen_t len) {
ShouldNotReachHere(); return ::connect(fd, him, len);
return 0;
} }
int os::accept(int fd, struct sockaddr* him, socklen_t* len) { int os::accept(int fd, struct sockaddr* him, socklen_t* len) {
ShouldNotReachHere(); return ::accept(fd, him, len);
return 0;
} }
int os::sendto(int fd, char* buf, size_t len, uint flags, int os::sendto(int fd, char* buf, size_t len, uint flags,
struct sockaddr* to, socklen_t tolen) { 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, int os::recvfrom(int fd, char *buf, size_t nBytes, uint flags,
sockaddr* from, socklen_t* fromlen) { 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) { int os::recv(int fd, char* buf, size_t nBytes, uint flags) {
ShouldNotReachHere(); return ::recv(fd, buf, (int)nBytes, flags);
return 0;
} }
int os::send(int fd, char* buf, size_t nBytes, uint flags) { int os::send(int fd, char* buf, size_t nBytes, uint flags) {
ShouldNotReachHere(); return ::send(fd, buf, (int)nBytes, flags);
return 0;
} }
int os::raw_send(int fd, char* buf, size_t nBytes, uint flags) { int os::raw_send(int fd, char* buf, size_t nBytes, uint flags) {
ShouldNotReachHere(); return ::send(fd, buf, (int)nBytes, flags);
return 0;
} }
int os::timeout(int fd, long timeout) { int os::timeout(int fd, long timeout) {
ShouldNotReachHere(); fd_set tbl;
return 0; 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) { int os::get_host_name(char* name, int namelen) {
ShouldNotReachHere(); return ::gethostname(name, namelen);
return 0;
} }
int os::socket_shutdown(int fd, int howto) { int os::socket_shutdown(int fd, int howto) {
ShouldNotReachHere(); return ::shutdown(fd, howto);
return 0;
} }
int os::bind(int fd, struct sockaddr* him, socklen_t len) { int os::bind(int fd, struct sockaddr* him, socklen_t len) {
ShouldNotReachHere(); return ::bind(fd, him, len);
return 0;
} }
int os::get_sock_name(int fd, struct sockaddr* him, socklen_t* len) { int os::get_sock_name(int fd, struct sockaddr* him, socklen_t* len) {
ShouldNotReachHere(); return ::getsockname(fd, him, len);
return 0;
} }
int os::get_sock_opt(int fd, int level, int optname, int os::get_sock_opt(int fd, int level, int optname,
char* optval, socklen_t* optlen) { char* optval, socklen_t* optlen) {
ShouldNotReachHere(); return ::getsockopt(fd, level, optname, optval, optlen);
return 0;
} }
int os::set_sock_opt(int fd, int level, int optname, int os::set_sock_opt(int fd, int level, int optname,
const char* optval, socklen_t optlen) { const char* optval, socklen_t optlen) {
ShouldNotReachHere(); return ::setsockopt(fd, level, optname, optval, optlen);
return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册