aboutsummaryrefslogtreecommitdiff
path: root/libjava/gnu/java
diff options
context:
space:
mode:
authorMichael Koch <konqueror@gmx.de>2003-11-22 16:49:47 +0000
committerMichael Koch <mkoch@gcc.gnu.org>2003-11-22 16:49:47 +0000
commit343c49ce753ba631174df2a3898b1e16ac4aba4b (patch)
tree07b85030c05a2a3bd9173046e8a48efddd22af29 /libjava/gnu/java
parentcf2348cb34832645326d71c306ac25d12bec5e60 (diff)
downloadgcc-343c49ce753ba631174df2a3898b1e16ac4aba4b.zip
gcc-343c49ce753ba631174df2a3898b1e16ac4aba4b.tar.gz
gcc-343c49ce753ba631174df2a3898b1e16ac4aba4b.tar.bz2
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. (send): Use offset in datagram packet. From-SVN: r73843
Diffstat (limited to 'libjava/gnu/java')
-rw-r--r--libjava/gnu/java/net/natPlainDatagramSocketImplPosix.cc12
1 files changed, 7 insertions, 5 deletions
diff --git a/libjava/gnu/java/net/natPlainDatagramSocketImplPosix.cc b/libjava/gnu/java/net/natPlainDatagramSocketImplPosix.cc
index 89c5055..f0e7ed7 100644
--- a/libjava/gnu/java/net/natPlainDatagramSocketImplPosix.cc
+++ b/libjava/gnu/java/net/natPlainDatagramSocketImplPosix.cc
@@ -208,7 +208,8 @@ gnu::java::net::PlainDatagramSocketImpl::peekData (::java::net::DatagramPacket *
// 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;
// Do timeouts via select since SO_RCVTIMEO is not always available.
@@ -228,7 +229,7 @@ gnu::java::net::PlainDatagramSocketImpl::peekData (::java::net::DatagramPacket *
}
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 < 0)
goto error;
@@ -290,7 +291,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;
@@ -327,7 +328,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;
// Do timeouts via select since SO_RCVTIMEO is not always available.
@@ -347,7 +349,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;