Skip to content

Commit

Permalink
clean-up byte reading code, and simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
n8fr8 committed Feb 16, 2022
1 parent 4231a8f commit b2bed02
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -338,20 +338,18 @@ public void writePacket(byte[] packet) {
public void run ()
{

// Allocate the buffer for a single packet.
ByteBuffer buffer = ByteBuffer.allocate(32767);

byte[] buffer = new byte[32767*2]; //64k
keepRunningPacket = true;
while (keepRunningPacket)
{
try {

int pLen = fis.read(buffer.array());
int pLen = fis.read(buffer);
if (pLen > 0)
{
buffer.limit(pLen);
byte[] pdata = buffer.array();
Packet packet = null;
byte[] pdata = Arrays.copyOf(buffer, pLen);
Packet packet;

try {
packet = (Packet) IpSelector.newPacket(pdata,0,pdata.length);

Expand All @@ -375,7 +373,6 @@ public void run ()
} catch (IllegalRawDataException e) {
return;
}
buffer.clear();

}
} catch (Exception e) {
Expand Down

0 comments on commit b2bed02

Please sign in to comment.