New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong value returned by RawDatagramSocket.send() #31873

sgrekhov opened this Issue Jan 12, 2018 · 0 comments


None yet
2 participants

sgrekhov commented Jan 12, 2018

According to the RawDatagramSocket.send()

Returns the number of bytes written. This will always be either the size of buffer or 0.
In fact, when buffer size is more than 65536 (on Windows) then returned value is always 65536

import "dart:io";

int maxLength = 66000;

main() {
  var address = InternetAddress.LOOPBACK_IP_V4;
  RawDatagramSocket.bind(address, 0).then((producer) {
    RawDatagramSocket.bind(address, 0).then((receiver) {
      receiver.listen((event) {

      List<int> sList = new List<int>(maxLength);
      for (int i = 0; i < maxLength; i++) {
        sList[i] = i & 0xff;
      print(producer.send(sList, address, receiver.port)); // 65536

Tested on Dart VM version: 2.0.0-dev.15.0 (Tue Jan 2 10:39:27 2018 +0100) on "windows_x64"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment