FYI: Patch: gnu.java.net.PlainDatagramSocketImpl

Mohan Embar gnustuff@thisiscool.com
Sun Nov 23 01:41:00 GMT 2003


Hi Michael,

>I will commit the attached patch to fix receiving and sending of udp
>packets reported by Norbert Freese.
>
>I haven't looked at the Win32 code but it may have the same problems.

Believe it or not, your patch applied to the corresponding Win32
file too. I checked it in and put your name in the ChangeLog.

-- Mohan
http://www.thisiscool.com/
http://www.animalsong.org/

ChangeLog
2003-11-22  Michael Koch  <konqueror@gmx.de>

	* gnu/java/net/natPlainDatagramSocketImplWin32.cc
	(peekData): Use offset and maximal free space in datagram packet.
	(receive): Likewise.
	(send): Use offset in datagram packet.

Index: gnu/java/net/natPlainDatagramSocketImplWin32.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/net/natPlainDatagramSocketImplWin32.cc,v
retrieving revision 1.4
diff -u -2 -r1.4 natPlainDatagramSocketImplWin32.cc
--- gnu/java/net/natPlainDatagramSocketImplWin32.cc	7 Nov 2003 03:13:55 -0000	1.4
+++ gnu/java/net/natPlainDatagramSocketImplWin32.cc	23 Nov 2003 01:33:58 -0000
@@ -203,5 +203,6 @@
   union SockAddr u;
   socklen_t addrlen = sizeof(u);
-  jbyte *dbytes = elements (p->getData());
+  jbyte *dbytes = elements (p->getData()) + p->getOffset();
+  jint maxlen = p->getData()->length - p->getOffset();
   ssize_t retlen = 0;
 
@@ -215,5 +216,5 @@
 
   retlen =
-    ::recvfrom (native_fd, (char *) dbytes, p->getLength(), MSG_PEEK, (sockaddr*) &u,
+    ::recvfrom (native_fd, (char *) dbytes, maxlen, MSG_PEEK, (sockaddr*) &u,
       &addrlen);
   if (retlen == SOCKET_ERROR)
@@ -281,5 +282,5 @@
   int len = haddress->length;
   struct sockaddr *ptr = (struct sockaddr *) &u.address;
-  jbyte *dbytes = elements (p->getData());
+  jbyte *dbytes = elements (p->getData()) + p->getOffset();
   if (len == 4)
     {
@@ -317,5 +318,6 @@
   union SockAddr u;
   socklen_t addrlen = sizeof(u);
-  jbyte *dbytes = elements (p->getData());
+  jbyte *dbytes = elements (p->getData()) + p->getOffset();
+  jint maxlen = p->getData()->length - p->getOffset();
   ssize_t retlen = 0;
 
@@ -332,5 +334,5 @@
 
   retlen =
-    ::recvfrom (native_fd, (char *) dbytes, p->getLength(), 0, (sockaddr*) &u,
+    ::recvfrom (native_fd, (char *) dbytes, maxlen, 0, (sockaddr*) &u,
       &addrlen);
   if (retlen < 0)





More information about the Java-patches mailing list