Skip to main content
Participant
June 5, 2011
Question

Join multicast group on AIR DatagramSocket ?

  • June 5, 2011
  • 2 replies
  • 2807 views

Hello Adobe experts,

I'm currently testing Flex/AIR for a new software that we have to design to display data received from the network and I'm very excited about all possibilities Flash offers in terms of UI and how easy it is to quickly develop a nice-looking, portable application, compared to other technologies (like Java, though richer in terms of API but harder to write code reusable for desktop, Internet and mobile apps, and not so good looking ).

The application itself gets data from a multicast group and formats it on the screen (images, graphs, ...).

So I'm really willing to use Flash to build this app and after a few benchmarking/prototyping I'm using a DatagramSocket (AIR-only, that's fine) to read UDP datagrams and it's working fine except for two tiny things on which I couldn't find any answer:

  1. I can't have the socket join a multicast group
  2. I can't set the send/receive buffer size for the socket

I have a lot of code in C and Java for that and both are just a single call to "setsockopt" function:

In C:

  1. setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, &group, sizeof(struct ip_mreq)) - where "group" describe the multicast group to join
  2. setsockopt(sock, SOL_SOCKET, SO_RCVBUF, &sz, sizeof(sz)) - where "sz" is the number of byte to use for the receive buffer

In Java it's even simpler, using a MulticastSocket:

  1. sock.joinGroup(group)
  2. sock.setReceiveBufferSize(sz)

I tried to use Alchemy to write simple functions to create an UDP socket and have it join a multicast group but alas, the "socket" call returns -1, as it seems that sockets cannot be created in Alchemy environment (though compilation works without problem...).

I find it hard to believe that I'm the only one needing these two tiny "setsockopt" calls... I found on Adobe forums people trying to set the TCP_NODELAY option on a socket (also using setsockopt in the end) but without success...

By the way, the data come from an electronic board and is somehow coded in VHDL so I can't use RTMFP on that, though it seems to implement the functionnalities I need (or at least the multicast group part, the receive buffer size would be a bonus).

Well, I'm rather disapointed by this as Flash fills remarkably 99.9% of the application needs but this tiny 0.1% makes it impossible for it to get the data, thus making it useless...

And we don't want that I turn to Silverlight, do we?

Thank you all for any help and answers on this topic!

Matthieu

This topic has been closed for replies.

2 replies

Participating Frequently
July 29, 2011

In the meanwhile I created a sample to do it with AIR if you need a Multicast UDP socket between AIR and other technolgies or hardware:

http://lucamezzalira.com/2011/07/29/multicast-udp-socket-in-adobe-air-with-python/

Participant
July 29, 2011

Thanks, that's what I was planning to do but in C or Java (everyone has its favorites right? ): use another program as a kind of "proxy" to redirect the multicast streams to local unicast AIR sockets...

But I'd rather have a nice API modification from Adobe on that matter. This kind of proxy is clearly "hacking" your way out of an API miss. You also have to make sure that your "proxy" is running on the local machine.

It's not as if multicast was a new technology or something nobody uses... It's standard and it's simple when you can already handle UDP sockets so I don't know why they don't want to implement these 10 lines of code...

Anyway, thank you for your answer, I'll stick to something similar (but I'll do Java ).

Matthieu

Participant
June 8, 2011

I found out another related post from 2 years ago, but the answer is quite recent.

Can anyone here confirm that it is NOT possible to have a UDP socket register on a multicast address?

Shall I then add an enhancement proposal on Adobe Jira?

Thanks!

Matthieu

Participant
June 25, 2011

I have created an enhancement request on Adobe's JIRA, as it seems that I'm not the only one interested in such a feature (Cf this post).

Please vote for it if you want Flash to improve as a network UI programming language!

Matthieu