UDP

Introduction

This page describes how to setup the UDP example application using Adobe AIR 2.0, PyAMF and Twisted.

Adobe AIR 2.0 now support UDP sockets allowing you to send and receive messages using the Universal Datagram Protocol (UDP). The example application also enumerates the list of hardware and software network interfaces available on the client computer.

Download

  1. Download and install the Adobe AIR 2 Runtime. Also download the Adobe AIR 2 SDK if you want to modify and compile the application.

  2. Grab the example from SVN with:

    svn export http://svn.pyamf.org/trunk/doc/tutorials/examples/actionscript/udp udp-example
    cd udp-example/python

    Alternatively, if you just want to have a look, you can browse the example online.

Server

Note: Make sure you have Twisted >= 2.5 installed.

The UDP server for the Adobe Flash Player starts on localhost:55555 when you launch the development server:

python server.py

You should see something like:

Registered alias 'org.pyamf.examples.air.udp.vo.HelloWorld' for class 'HelloWorld'
Server started listening on port 55555

Client

AIR

After you started the server you can simply install the AIR file, launch it and it will show you’re connected to localhost:55555, i.e.:

../../_images/udp-overview.png

The server terminal window shows it receiving and echoing back the HelloWorld instances:

Registered alias 'org.pyamf.examples.air.udp.vo.HelloWorld' for class 'HelloWorld'
Server started listening on port 55555
received <HelloWorld msg='UDP message' time=2009-12-28 19:36:53.370000 /> from 192.168.0.3:55554
received <HelloWorld msg='UDP message' time=2009-12-28 19:36:57.418000 /> from 192.168.0.3:55554
received <HelloWorld msg='UDP message' time=2009-12-28 19:37:01.418000 /> from 192.168.0.3:55554
received <HelloWorld msg='UDP message' time=2009-12-28 19:37:05.417000 /> from 192.168.0.3:55554
received <HelloWorld msg='UDP message' time=2009-12-28 19:37:09.417000 /> from 192.168.0.3:55554

Drag the window or resize it by dragging any of the sides or corners:

../../_images/udp-resize.png

Right-click for the fullscreen and always on top options:

../../_images/udp-options.png