Forgot to push new Class Ack
This commit is contained in:
parent
cc035d910a
commit
ccd2885c69
26
ws2012/P2P/uebungen/4/src/node/Ack.java
Normal file
26
ws2012/P2P/uebungen/4/src/node/Ack.java
Normal 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;
|
||||
}
|
||||
}
|
||||
18
ws2012/P2P/uebungen/4/src/util/BufferUtil.java
Normal file
18
ws2012/P2P/uebungen/4/src/util/BufferUtil.java
Normal 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;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user