18

Quick question: is there possibility to do UDP datagram sockets in Flash/ActionScript?

bdonlan
  • 224,562
  • 31
  • 268
  • 324
the dude
  • 233
  • 1
  • 2
  • 5

3 Answers3

19

This question was asked long ago, and the answer has since changed to Yes. For others who stumble across this question:

The DatagramSocket class enables UDP communication. For example:

var datagramSocket:DatagramSocket = new DatagramSocket();
datagramSocket.bind(3333, "127.0.0.1");
datagramSocket.addEventListener(DatagramSocketDataEvent.DATA, onUDPReceived);
datagramSocket.receive();

Note: DatagramSocket is only available for AIR for desktop, not for devices or for Flash Player.

ericsoco
  • 24,913
  • 29
  • 97
  • 127
5

Yes sort of..

The next version of FMS and Player 10 will introduce a new protocol, RTMFP, which stands for Real Time Messaging Flow Protocol. This is a low latency, UDP based protocol that is based on Amicima's MFP protocol. Amicima was aquired by Adobe in 2006.

Note that being a "UDP based protocol" it is not a raw UDP implementation.

SpliFF
  • 38,186
  • 16
  • 91
  • 120
  • What are the differences if I may ask? – Tom May 15 '10 at 18:07
  • RTMFP runs on top of UDP so it only has a subset of UDP's capabilities. On the other hand it saves you writing code for the features it does provide, namely encrypted p2p between flash clients. More more info see http://en.wikipedia.org/wiki/Real_Time_Media_Flow_Protocol – SpliFF Jul 04 '12 at 02:05
5

At the time of writing, the answer was no.

Both BinarySocket and Xml Socket is TCP/IP based. As SpliFF mentions UDP is being added in Flash 10 mainly for Flash Media Server tools and for RTMFP. Adobe Stratus is an example of the protocol so far. http://labs.adobe.com/technologies/stratus/

However current UDP samples from Adobe are all Peer-to-Peer based. UDP has benefits in P2P but more so in larger scale multiuser or DVEs (Distributed Virtual Environments) so hopefully it is focus going forward.

If you want UDP for a game Unity3D currently supports UDP in the web player. Or jMonkeyEngine using Java supports it. Also Torque 3D web based coming soon may also support it.

However, the answer has since changed to a yes; to see how this is now possible, see ericsoco's answer on how to use DatagramSocket to achieve this.

Community
  • 1
  • 1
Ryan Christensen
  • 7,843
  • 1
  • 27
  • 25