PORT msg support; port and extension listener stubs

This commit is contained in:
zzz
2010-12-19 15:37:11 +00:00
parent 91f1ece753
commit afe57512ab
7 changed files with 67 additions and 22 deletions

View File

@@ -53,6 +53,7 @@ class Message
// Used for HAVE, REQUEST, PIECE and CANCEL messages.
// low byte used for EXTENSION message
// low two bytes used for PORT message
int piece;
// Used for REQUEST, PIECE and CANCEL messages.
@@ -107,6 +108,9 @@ class Message
if (type == EXTENSION)
datalen += 1;
if (type == PORT)
datalen += 2;
// add length of data for piece or bitfield array.
if (type == BITFIELD || type == PIECE || type == EXTENSION)
datalen += len;
@@ -130,6 +134,9 @@ class Message
if (type == EXTENSION)
dos.writeByte((byte) piece & 0xff);
if (type == PORT)
dos.writeShort(piece & 0xffff);
// Send actual data
if (type == BITFIELD || type == PIECE || type == EXTENSION)
dos.write(data, off, len);