Forgot to push new Class Ack

This commit is contained in:
senft-lap 2012-11-27 16:21:54 +01:00
parent cc035d910a
commit ccd2885c69
2 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,26 @@
package node;
import java.net.SocketAddress;
import java.nio.ByteBuffer;
public class Ack {
private SocketAddress address;
private ByteBuffer buf;
public Ack(SocketAddress address) {
this.address = address;
}
public boolean check(SocketAddress address) {
return this.address.toString().equals(address.toString());
}
public ByteBuffer getBuf() {
return buf;
}
public void setBuf(ByteBuffer buf) {
this.buf = buf;
}
}

View File

@ -0,0 +1,18 @@
package util;
import java.nio.ByteBuffer;
public class BufferUtil {
public static ByteBuffer clone(ByteBuffer original) {
ByteBuffer clone = ByteBuffer.allocate(original.capacity());
int oldPosition = original.position();
original.rewind();// copy from the beginning
clone.put(original);
// original.rewind();
original.position(oldPosition);
clone.flip();
return clone;
}
}