protected void write(NetSocket socket) {
int length = 1 + 1 + 4 + address.length() + 1 + 4 * sender.host.length() +
4 + (replyAddress == null ? 0 : replyAddress.length()) +
getBodyLength();
Buffer totBuff = new Buffer(length);
totBuff.appendInt(0);
totBuff.appendByte(type());
totBuff.appendByte(send ? (byte)0 : (byte)1);
writeString(totBuff, address);
totBuff.appendInt(sender.port);
writeString(totBuff, sender.host);