Skip to content

Commit

Permalink
AFDatagramSocketImpl: Set ByteBuffer positions
Browse files Browse the repository at this point in the history
  • Loading branch information
kohlschuetter committed Jun 26, 2023
1 parent bf980c5 commit 3c4dc85
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ protected final void send(DatagramPacket p) throws IOException {
sendToBuf = AFSocketAddress.SOCKETADDRESS_BUFFER_TL.get();
sendToBufLen = NativeUnixSocket.bytesToSockAddr(getAddressFamily().getDomain(), sendToBuf,
addrBytes);
sendToBuf.position(0);
if (sendToBufLen == -1) {
throw new SocketException("Unsupported domain");
}
Expand All @@ -219,6 +220,8 @@ protected final void send(DatagramPacket p) throws IOException {
ByteBuffer datagramPacketBuffer = core.getThreadLocalDirectByteBuffer(len);
datagramPacketBuffer.clear();
datagramPacketBuffer.put(p.getData(), p.getOffset(), p.getLength());
datagramPacketBuffer.flip();

NativeUnixSocket.send(fdesc, datagramPacketBuffer, 0, len, sendToBuf, sendToBufLen,
/* NativeUnixSocket.OPT_NON_BLOCKING | */
NativeUnixSocket.OPT_DGRAM_MODE, ancillaryDataSupport);
Expand Down

0 comments on commit 3c4dc85

Please sign in to comment.