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

RawDatagramSocket.multicastInterface= not implemented #17057

Closed
DartBot opened this issue Feb 24, 2014 · 7 comments
Closed

RawDatagramSocket.multicastInterface= not implemented #17057

DartBot opened this issue Feb 24, 2014 · 7 comments
Labels
area-library library-io type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@DartBot
Copy link

DartBot commented Feb 24, 2014

This issue was originally filed by j.m.s...@gmail.com


What steps will reproduce the problem?

  1. Create a RawDatagramSocket object
  2. Try to set the multicastInterface property to a different NetworkInterface object

What is the expected output? What do you see instead?
The socket should now send all multicast packet out of the network card represented by the NetworkInterface object. Instead it throws an exception and fails with a stack trace.

$ dart multicast_eth0_send.dart
found eth0
Uncaught Error: Not implemented
Stack Trace:

­0 _RawDatagramSocket.multicastInterface= (dart:io-patch/socket_patch.dart:1513)

­1 openUdpSocket.<anonymous closure> (file:///home/james/projects/dart/udpsockets/multicast_eth0_send.dart:22:7)

­2 _Future._propagateToListeners.<anonymous closure> (dart:async/future_impl.dart:453)

­3 _rootRun (dart:async/zone.dart:683)

­4 _RootZone.run (dart:async/zone.dart:832)

­5 _Future._propagateToListeners (dart:async/future_impl.dart:445)

­6 _Future._complete (dart:async/future_impl.dart:303)

­7 _Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:354)

­8 _asyncRunCallback (dart:async/schedule_microtask.dart:18)

­9 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:119)

Unhandled exception:
Not implemented

­0 _rootHandleUncaughtError.<anonymous closure>.<anonymous closure> (dart:async/zone.dart:677)

­1 _asyncRunCallback (dart:async/schedule_microtask.dart:18)

­2 _asyncRunCallback (dart:async/schedule_microtask.dart:21)

­3 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:119)

What version of the product are you using? On what operating system?
Dart VM version: 1.1.3 (Thu Feb 6 00:04:34 2014) on "linux_x64"

Please provide any additional information below.
The API documentation states that this property should be settable.
https://api.dartlang.org/apidocs/channels/stable/#dart-io.RawDatagramSocket@id_multicastInterface

Please see attached file for an example. if you comment out line 22 s.multicastInterface = interface;
then this program works fine.


Attachment:
multicast_eth0_send.dart (1 KB)

@sethladd
Copy link
Contributor

Added Area-IO, Triaged labels.

@kevmoo
Copy link
Member

kevmoo commented May 14, 2014

Removed Area-IO label.
Added Library-IO label.

@kevmoo kevmoo added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed priority-unassigned labels Feb 29, 2016
@bkonyi
Copy link
Contributor

bkonyi commented Jun 28, 2018

Confirmed this is still an issue in Dart 2:

#0      _RawDatagramSocket.multicastInterface= (dart:io/runtime/binsocket_patch.dart:1832:7)
#1      openUdpSocket.<anonymous closure> (file:///usr/local/google/home/bkonyi/sdk/tmp.dart:22:7)
#2      _RootZone.runUnary (dart:async/zone.dart:1381:54)
#3      _FutureListener.handleValue (dart:async/future_impl.dart:129:18)
#4      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:638:45)
#5      Future._propagateToListeners (dart:async/future_impl.dart:667:32)
#6      Future._complete (dart:async/future_impl.dart:472:7)
#7      _SyncCompleter.complete (dart:async/future_impl.dart:51:12)
#8      _AsyncAwaitCompleter.complete (dart:async/runtime/libasync_patch.dart:28:18)
#9      _NativeSocket.bindDatagram (dart:io/runtime/binsocket_patch.dart)
<asynchronous suspension>
#10     _RawDatagramSocket.bind (dart:io/runtime/binsocket_patch.dart:1778:10)
#11     RawDatagramSocket.bind (dart:io/runtime/binsocket_patch.dart:1737:31)
#12     openUdpSocket (file:///usr/local/google/home/bkonyi/sdk/tmp.dart:21:21)
#13     main.<anonymous closure> (file:///usr/local/google/home/bkonyi/sdk/tmp.dart:14:9)
#14     _RootZone.runUnary (dart:async/zone.dart:1381:54)
#15     _FutureListener.handleValue (dart:async/future_impl.dart:129:18)
#16     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:638:45)
#17     Future._propagateToListeners (dart:async/future_impl.dart:667:32)
#18     Future._completeWithValue (dart:async/future_impl.dart:482:5)
#19     Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:512:7)
#20     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#21     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#22     _runPendingImmediateCallback (dart:isolate/runtime/libisolate_patch.dart:113:13)
#23     _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:166:5)

@dnfield
Copy link
Contributor

dnfield commented Oct 30, 2018

I want this for support for a Multicast DNS client.

https://dart-review.googlesource.com/c/sdk/+/82024

@dnfield
Copy link
Contributor

dnfield commented Jan 11, 2019

Quick update on this -

I'm working on implementing a more generic interface for setting socket options.

Setting the multicast interface is very significantly different for IPv4 vs. IPv6. This property can't sensibly be implemented without breaking it, and making it much different from the other options exposed in this manner. Exposing the ability to set arbitrary options will help to fix that.

dart-bot pushed a commit that referenced this issue Jan 17, 2019
This allows developers to have more fine grained control over socket
options supported by their platforms, particularly when there is not a
nice way to encapsulate differences between IPv4 and IPv6 options (as
with IP_MULTICAST_IF and IPV6_MULTICAST_IF).  It also begins the work
of exposing socket level and option values, although keeping it for now
only to a minimum necessary to assist with setting the multicast
interface for datagram sockets.

This CL also marks `multicastInterface` as deprecated.

Bug: #17057
Change-Id: I39b3bf3d32d39de1c777acea4425d6eb2226355d
Reviewed-on: https://dart-review.googlesource.com/c/89164
Commit-Queue: Zach Anderson <zra@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
@dnfield
Copy link
Contributor

dnfield commented Jan 18, 2019

As of 5b1daaa, this property is marked @Deprecated.

The way to do this now is:

    if (targetAddress.type == InternetAddressType.IPv4) {
        socket.setRawOption(RawSocketOption(
          RawSocketOption.levelIPv4,
          RawSocketOption.IPv4MulticastInterface,
          address.rawAddress, // where address is an InternetAddress
        ));
      } else {
        socket.setRawOption(RawSocketOption.fromInt(
          RawSocketOption.levelIPv6,
          RawSocketOption.IPv6MulticastInterface,
          interface.index, // where interface is a NetworkInterface
        ));
      }

@brianquinlan
Copy link
Contributor

So @dnfield , can we close this issue?

@dnfield dnfield closed this as completed Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-library library-io type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

6 participants