Skip to content
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

mutiple requests not work #26

Open
jplajpla23 opened this issue Nov 30, 2023 · 0 comments
Open

mutiple requests not work #26

jplajpla23 opened this issue Nov 30, 2023 · 0 comments

Comments

@jplajpla23
Copy link

Im design an app that send a UDP broadcast.
my code is simple send a fixed packet when i click in button. this is the function that is called. nut the problem is that the frist time work, the second show sent X bytes but not receive anything in others devices or response. i check with wireshart and the packet is not sent. sometimes can send 2/3 times but some only the first

searchDevices() async {

var sender = await UDP.bind(Endpoint.any(port: Port.any));
devices=[];

sender.socket?.broadcastEnabled=true;
// send a simple string to a broadcast endpoint on port 65001.

//sender.as

// creates a new UDP instance and binds it to the local address and the port
// 65002.
//var receiver = await UDP.bind(Endpoint.any(port: Port.any));
//receiver.socket?.broadcastEnabled=true;
// receiving\listening
sender.asStream(timeout: Duration(seconds: 5)).listen((datagram) {
  var str = String.fromCharCodes(datagram!.data);
  print(str);
  devices.add(str);

  ScaffoldMessenger.of(context).showSnackBar(
    SnackBar(content: Text(str)),
  );

  // receiver.close();
});


var dataLength = await sender.send( numbers, Endpoint.broadcast(port: Port(9998)));

print('$dataLength bytes sent.');
//receiver.socket.broadcastEnabled


// close the UDP instances and their sockets.
await Future.delayed(Duration(seconds: 5)); // Wait for responses.

// sender.close();

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant