diff options
-rw-r--r-- | libjava/ChangeLog | 7 | ||||
-rw-r--r-- | libjava/gnu/java/net/natPlainDatagramSocketImplWin32.cc | 12 |
2 files changed, 14 insertions, 5 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index f5a23b2..938a517 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,5 +1,12 @@ 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. + +2003-11-22 Michael Koch <konqueror@gmx.de> + * gnu/java/net/natPlainDatagramSocketImplPosix.cc (peekData): Use offset and maximal free space in datagram packet. (receive): Likewise. diff --git a/libjava/gnu/java/net/natPlainDatagramSocketImplWin32.cc b/libjava/gnu/java/net/natPlainDatagramSocketImplWin32.cc index 4a4ec98..15105b96 100644 --- a/libjava/gnu/java/net/natPlainDatagramSocketImplWin32.cc +++ b/libjava/gnu/java/net/natPlainDatagramSocketImplWin32.cc @@ -202,7 +202,8 @@ gnu::java::net::PlainDatagramSocketImpl::peekData(::java::net::DatagramPacket *p // FIXME: Deal with Multicast and if the socket is connected. 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; if (timeout > 0) @@ -214,7 +215,7 @@ gnu::java::net::PlainDatagramSocketImpl::peekData(::java::net::DatagramPacket *p } 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) goto error; @@ -280,7 +281,7 @@ gnu::java::net::PlainDatagramSocketImpl::send (::java::net::DatagramPacket *p) jbyte *bytes = elements (haddress); 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) { u.address.sin_family = AF_INET; @@ -316,7 +317,8 @@ gnu::java::net::PlainDatagramSocketImpl::receive (::java::net::DatagramPacket *p // FIXME: Deal with Multicast and if the socket is connected. 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; if (timeout > 0) @@ -331,7 +333,7 @@ gnu::java::net::PlainDatagramSocketImpl::receive (::java::net::DatagramPacket *p } retlen = - ::recvfrom (native_fd, (char *) dbytes, p->getLength(), 0, (sockaddr*) &u, + ::recvfrom (native_fd, (char *) dbytes, maxlen, 0, (sockaddr*) &u, &addrlen); if (retlen < 0) goto error; |