Creating a Web Server using the new Server Socket API in AIR 2

Creating a Web Server using the new Server Socket API in AIR 2

During the Adobe AIR 2 beta, I wrote a simple Web Server application to explore the new Server Socket API available in AIR 2. Here is the updated version of the application for AIR 2 GA.

The “Mini AIR Web Server” is a simplistic implementation of an HTTPServer. Needless to say that it is far from being a production quality Web Server. The goal here is simply to use the well understood mechanics of a web server to learn how to use server sockets in AIR 2.0.

Installation Instructions

Make sure you have the AIR 2 runtime installed (you can download the AIR 2 runtime here), and install the application using the badge below:

Please upgrade your Flash Player This is the content that would be shown if the user does not have Flash Player 9.0.115 or higher installed.

Testing the Application

To test the application, open a browser and test the sample HTML pages provided with the application:

NOTE: You may have to change the port number in these URLs depending on the port number you enter in the application.

You can add your own content in the webroot folder in the applicationStorageDirectory.

Downloading the project

Click here to download the project

  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • LinkedIn
  • StumbleUpon
  • Twitter
This entry was posted in Air, Flex. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

6 Comments

  1. Posted July 9, 2010 at 2:49 pm | Permalink

    Darn that is actually COOL!

    The usage of this could be endless in some levels.
    How about FTP ? Is there any way to support FTP ?
    Ive created a app that uses php on webserver but it is mean to use with FTP servers, looks like i have to wait till a nice FTP API

  2. Grégory Pelletier
    Posted July 9, 2010 at 3:04 pm | Permalink

    Thank you for this nice sample!
    Do you know this issue :
    http://bugs.adobe.com/jira/browse/FP-6
    has been fixed in Air2 because I’ve seen in the sample the Socket class is used in write mode and because of the issue mentioned above, this could imply some limitations in a professional project.

  3. Posted July 10, 2010 at 5:14 am | Permalink

    That’s new life for flash^^

  4. Wouter Coekaerts
    Posted July 12, 2010 at 10:45 am | Permalink

    Nice short example!

    I know that this is “far from being a production quality Web Server”, and it wouldn’t make sense to start pointing out everything in it that would have to be improved before it would be really usable…
    But still, because it is a sample that is distributed to other developers (who will run it, and might use it as a basis for more), it would be better not expose the whole hard drive to the world through a directory traversal attack. A simple check if filePath contains “..” will probably do the trick.

  5. Posted August 1, 2010 at 3:47 pm | Permalink

    bedava sinirsiz sorunsuz dinle iste.

  6. Daniel
    Posted August 12, 2010 at 1:19 pm | Permalink

    I’m having a problem in 30s with AIR 2.0/BlazeDS request.. My project is almost finished. Can you help me? The error is not a requestTimeout. Error message: http://bit.ly/9m5Jwv

4 Trackbacks

  1. [...] Direct Link [...]

  2. [...] Creating a Web Server using the new Server Socket API in AIR 2 [...]

  3. [...]       理解Flash Player 10.1和AIR2里的安全变化 •        使用AIR2里新的Server Socket访问一个Web Server •        探索“以默认应用开始的”API •        [...]

  4. [...] 2•        理解Flash Player 10.1和AIR2里的安全变化•        使用AIR2里新的Server Socket访问一个Web Server•        探索“以默认应用开始的”API•        [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>