This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
WIN-24: natPlainDatagramSocket.cc
- From: Adam Megacz <patches at lists dot megacz dot com>
- To: java-patches at gcc dot gnu dot org
- Date: 24 Feb 2002 15:38:58 -0800
- Subject: WIN-24: natPlainDatagramSocket.cc
- Organization: Myself
Okay, I'd like to commit the patch below, which will make datagram
sockets work on Win32, *without* support for timeouts. Getting
timeouts to work is probably going to require some discussion and
possibly changes to how the POSIX side works. For that reason, I'd
like to commit this now and fix timeouts at a later date, figuring
that a compiling libgcj without Win32 timeouts is better than one that
doesn't compile at all =)
Is it okay to commit the patch below until we decide on the best way
to handle timeouts?
<discussion>
Here's the issue. natPlainDatagramSocket uses select() on a single
file descriptor to achieve timeouts since socket-level timeouts aren't
always available on POSIX. Win32 provides select() ONLY for sockets --
not for normal file descriptors. Win32 also always provides
socket-level timeouts, and, AFAIK from the docs I have, you don't have
to worry about EINTR's unless you explicitly WSACancelBlockingCall().
I'd rather not write a _Jv_select() for Win32, because I'm afraid that
will lead people to try to use it on normal file descriptors.
Could we create some sort of _Jv_socket_read_with_timeout in
{win32|posix}.cc, which would call _Jv_select() on POSIX and recv()
with a timeout on Win32?
</discussion>
- a
2002-02-24 Adam Megacz <adam@xwt.org>
* java/net/natPlainDatagramSocketImpl.cc: Updated #includes
for Win32, changed #ifdefs to check WIN32 instead of the
(now-obsolete) USE_WINSOCK, and removed support for socket
timeouts on Win32 pending further discussion.
Index: natPlainDatagramSocketImpl.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/natPlainDatagramSocketImpl.cc,v
retrieving revision 1.31
diff -u -r1.31 natPlainDatagramSocketImpl.cc
--- natPlainDatagramSocketImpl.cc 2002/02/18 07:32:34 1.31
+++ natPlainDatagramSocketImpl.cc 2002/02/24 23:39:44
@@ -8,15 +8,16 @@
#include <config.h>
-#ifdef USE_WINSOCK
+#ifdef WIN32
#include <windows.h>
#include <winsock.h>
#include <errno.h>
#include <string.h>
+#undef STRICT
#ifndef ENOPROTOOPT
#define ENOPROTOOPT 109
#endif
-#else /* USE_WINSOCK */
+#else /* WIN32 */
#include "posix.h"
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
@@ -29,7 +30,7 @@
#endif
#include <errno.h>
#include <string.h>
-#endif /* USE_WINSOCK */
+#endif /* WIN32 */
#if HAVE_BSTRING_H
// Needed for bzero, implicitly used by FD_ZERO on IRIX 5.2
@@ -328,6 +329,8 @@
jbyte *dbytes = elements (p->getData());
ssize_t retlen = 0;
+// FIXME: implement timeout support for Win32
+#ifndef WIN32
// Do timeouts via select since SO_RCVTIMEO is not always available.
if (timeout > 0)
{
@@ -343,6 +346,7 @@
else if (retval == 0)
throw new java::io::InterruptedIOException ();
}
+#endif /* WIN32 */
retlen =
::recvfrom (fnum, (char *) dbytes, p->getLength(), 0, (sockaddr*) &u,