aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Megacz <adam@xwt.org>2002-03-08 01:46:34 +0000
committerAdam Megacz <megacz@gcc.gnu.org>2002-03-08 01:46:34 +0000
commit4e0020277270d90f7237d372eb86eb7c7b93b4a5 (patch)
tree01fcfa04a840aa339f42e72d38cefe1acf04be94
parent8eeda6e0e760b631414f9272beedfb6c007c5ad4 (diff)
downloadgcc-4e0020277270d90f7237d372eb86eb7c7b93b4a5.zip
gcc-4e0020277270d90f7237d372eb86eb7c7b93b4a5.tar.gz
gcc-4e0020277270d90f7237d372eb86eb7c7b93b4a5.tar.bz2
natPlainSocketImpl.cc: Changed USE_WINSOCK to WIN32, and added thunks for read(), write(), and close().
2002-03-07 Adam Megacz <adam@xwt.org> * java/net/natPlainSocketImpl.cc: Changed USE_WINSOCK to WIN32, and added thunks for read(), write(), and close(). * java/net/natPlainSocketImpl.cc (accept, read, read): Disabled timeouts on WIN32 pending discussion. From-SVN: r50418
-rw-r--r--libjava/ChangeLog7
-rw-r--r--libjava/java/net/natPlainSocketImpl.cc40
2 files changed, 44 insertions, 3 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index 7c12541..7483b4c 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,5 +1,12 @@
2002-03-07 Adam Megacz <adam@xwt.org>
+ * java/net/natPlainSocketImpl.cc: Changed USE_WINSOCK to
+ WIN32, and added thunks for read(), write(), and close().
+ * java/net/natPlainSocketImpl.cc (accept, read, read):
+ Disabled timeouts on WIN32 pending discussion.
+
+2002-03-07 Adam Megacz <adam@xwt.org>
+
* win32.cc (_Jv_platform_gettimeofday): Now takes no args,
returns jlong. Added implementation
* posix.cc (_Jv_platform_gettimeofday): Now takes no args,
diff --git a/libjava/java/net/natPlainSocketImpl.cc b/libjava/java/net/natPlainSocketImpl.cc
index 9071430..7090fcd 100644
--- a/libjava/java/net/natPlainSocketImpl.cc
+++ b/libjava/java/net/natPlainSocketImpl.cc
@@ -10,22 +10,45 @@ details. */
#ifndef DISABLE_JAVA_NET
-#ifdef USE_WINSOCK
+#ifdef WIN32
#include <windows.h>
#include <winsock.h>
#include <errno.h>
#include <string.h>
+#undef STRICT
+#undef MAX_PRIORITY
+#undef MIN_PRIORITY
+#undef FIONREAD
+
+// stuff to make Win32 look POSIXy
+static inline int close(int s) {
+ return closesocket(s);
+}
+
+static inline int write(int s, void *buf, int len)
+{
+ return send(s, (char*)buf, len, 0);
+}
+
+static inline int read(int s, void *buf, int len)
+{
+ return recv(s, (char*)buf, len, 0);
+}
+
+// these errors cannot occur on Win32
+#define ENOTCONN 0
+#define ECONNRESET 0
#ifndef ENOPROTOOPT
#define ENOPROTOOPT 109
#endif
-#else /* USE_WINSOCK */
+#else /* WIN32 */
#include "posix.h"
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <errno.h>
#include <string.h>
-#endif /* USE_WINSOCK */
+#endif /* WIN32 */
#endif /* DISABLE_JAVA_NET */
#if HAVE_BSTRING_H
@@ -325,6 +348,8 @@ java::net::PlainSocketImpl::accept (java::net::PlainSocketImpl *s)
socklen_t addrlen = sizeof(u);
int new_socket = 0;
+// FIXME: implement timeout support for Win32
+#ifndef WIN32
// Do timeouts via select since SO_RCVTIMEO is not always available.
if (timeout > 0)
{
@@ -341,6 +366,7 @@ java::net::PlainSocketImpl::accept (java::net::PlainSocketImpl *s)
throw new java::io::InterruptedIOException (
JvNewStringUTF("Accept timed out"));
}
+#endif /* WIN32 */
new_socket = _Jv_accept (fnum, (sockaddr*) &u, &addrlen);
if (new_socket < 0)
@@ -461,6 +487,8 @@ java::net::PlainSocketImpl::read(void)
{
jbyte b;
+// FIXME: implement timeout support for Win32
+#ifndef WIN32
// Do timeouts via select.
if (timeout > 0)
{
@@ -482,6 +510,8 @@ java::net::PlainSocketImpl::read(void)
// If select returns ok we know we either got signalled or read some data...
// either way we need to try to read.
}
+#endif /* WIN32 */
+
int r = ::read (fnum, &b, 1);
if (r == 0)
@@ -516,6 +546,8 @@ java::net::PlainSocketImpl::read(jbyteArray buffer, jint offset, jint count)
throw new java::lang::ArrayIndexOutOfBoundsException;
jbyte *bytes = elements (buffer) + offset;
+// FIXME: implement timeout support for Win32
+#ifndef WIN32
// Do timeouts via select.
if (timeout > 0)
{
@@ -541,6 +573,8 @@ java::net::PlainSocketImpl::read(jbyteArray buffer, jint offset, jint count)
throw iioe;
}
}
+#endif
+
// Read the socket.
int r = ::recv (fnum, (char *) bytes, count, 0);
if (r == 0)