Commit a300a155 authored by Daniel Wolf's avatar Daniel Wolf

Copy packets to size

parent fcc47943
......@@ -193,13 +193,13 @@ open class SocketBasedFutureAnswer<T>(token: DeviceWriteToken,
val inStream = DataInputStream(it.getInputStream())
val data = ByteArray(inStream.readUnsignedShort())
val actualRead = inStream.read(data)
ReceivedAnswer(data, socket, actualRead)
ReceivedAnswer(data.copyOf(actualRead), socket, actualRead)
}
is DatagramSocket -> {
val datagramData = ByteArray(udpPacketSize)
val replyPacket = DatagramPacket(datagramData, datagramData.size)
it.receive(replyPacket)
ReceivedAnswer(datagramData, socket)
ReceivedAnswer(datagramData.copyOf(replyPacket.length), socket)
}
else -> throw IllegalStateException()
}
......@@ -248,13 +248,13 @@ abstract class SocketBasedNonPollableFutureAnswer<T>(token: DeviceWriteToken,
val inStream = DataInputStream(it.getInputStream())
val data = ByteArray(inStream.readUnsignedShort())
val actualRead = inStream.read(data)
ReceivedAnswer(data, socket, actualRead)
ReceivedAnswer(data.copyOf(actualRead), socket, actualRead)
}
is DatagramSocket -> {
val datagramData = ByteArray(udpPacketSize)
val replyPacket = DatagramPacket(datagramData, datagramData.size)
it.receive(replyPacket)
ReceivedAnswer(datagramData, socket)
ReceivedAnswer(datagramData.copyOf(replyPacket.length), socket)
}
else -> throw IllegalStateException()
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment