setOptionWithLength method
Adds the option to the TCP options. Returns index of the option.
Implementation
int setOptionWithLength(int code, int length) {
removeOption(code);
final oldOptions = optionsByteData;
final newOptions = ByteData(oldOptions.lengthInBytes + length);
var i = 0;
for (; i < oldOptions.lengthInBytes; i++) {
newOptions.setUint8(i, oldOptions.getUint8(i));
}
final result = i;
newOptions.setUint8(i, code);
if (length > 1) {
i++;
newOptions.setUint8(i, length);
}
optionsByteData = newOptions;
return result;
}