UDP

Introduction

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

Adobe AIR >= 2.0 supports UDP sockets, allowing you to send and receive messages using the Universal Datagram Protocol (UDP).

The example application shows you how to echo a typed object every x seconds and display the active hardware and software network interfaces that are available on the client computer.

Download

  1. Download and install the Adobe AIR runtime. Also download the Adobe AIR SDK if you want to modify and compile the application.
  2. Clone the PyAMF repository with:
git clone git://github.com/hydralabs/pyamf.git pyamf
cd doc/tutorials/examples/actionscript/udp-example

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