Adobe
Products
Acrobat
Creative Cloud
Creative Suite
Digital Marketing Suite
Digital Publishing Suite
Elements
Photoshop
Touch Apps
Student and Teacher Editions
More products
Solutions
Creative tools for business
Digital marketing
Digital media
Education
Financial services
Government
Web Experience Management
More solutions
Learning Help Downloads Company
Buy
Home use for personal and home office
Education for students, educators, and staff
Business for small and medium businesses
Licensing programs for businesses, schools, and government
Special offers
Search
 
Info Sign in
Welcome,
My cart
My orders My Adobe
My Adobe
My orders
My information
My preferences
My products and services
Sign out
Why sign in? Sign in to manage your account and access trial downloads, product extensions, community areas, and more.
Adobe
Products Sections Buy   Search  
Solutions Company
Help Learning
Sign in Sign out My orders My Adobe
Preorder Estimated Availability Date. Your credit card will not be charged until the product is shipped. Estimated availability date is subject to change. Preorder Estimated Availability Date. Your credit card will not be charged until the product is ready to download. Estimated availability date is subject to change.
Qty:
Purchase requires verification of academic eligibility
Subtotal
Review and Checkout
Adobe Developer Connection / Adobe AIR Developer Center /

Retrieving a list of network interfaces in Adobe AIR 2

by William Liang

William Liang

Modified

10 June 2010

Page tools

Share on Facebook
Share on Twitter
Share on LinkedIn
Bookmark
Print
ActionScript Adobe AIR Flex networking

Requirements

Prerequisite knowledge

This article is intended for developers who are comfortable with ActionScript and who have a basic understanding of networking.

User Level

All

Required products

  • Adobe AIR

Among the new networking features introduced in Adobe AIR 2 is the ability to enumerate all hardware and software network interfaces. This list of network interfaces includes information about each interface such as IP address, MAC address, status, and more.

This article describes the new NetworkInfo class and the information it provides; you can use this information to implement peer-to-peer features and advanced networking applications.

NetworkInfo use cases and class overview

Enumerating all hardware and software network interfaces reveals detailed information about the networking capabilities of the local machine. This information is required for many advanced networking features. For example, peer-to-peer and Voice-over-IP (VoIP) applications frequently need to be able to traverse Network Address Translation (NAT) gateways. In order to traverse a NAT, an application typically needs the list of available network interfaces. The application can then probe each interface to determine if it can be used to traverse the NAT and establish a connection with a remote client.

Peer-to-peer applications often also need to obtain a list of available interfaces and their capabilities. For example, when a Session Initiation Protocol (SIP) client wants to establish a connection with another SIP client, the two clients need to exchange their capabilities. These capabilities include the networking capabilities of the local machine and the networking between them.

In AIR 2, you can now incorporate network information within your application, so you can implement standard networking or peer-to-peer features, such as the ones listed above, or develop new ones.

NetworkInfo class overview

The new NetworkInfo class is analogous to ipconfig on Windows and ifconfig on Mac OS X or Linux. NetworkInfo returns a list of network interfaces and the following information for each interface:

  • Name
  • Display name
  • MTU
  • Hardware address (or MAC address)
  • Active (or status)
  • Address (or IP address)
  • Broadcast address
  • Prefix length
  • IP version (or IP Family)

Using the NetworkInfo class

NetworkInfo is a singleton class. The code below is a simple example of how to use it to display information about the local machine's network interfaces.

import flash.net.NetworkInfo; public function findInterface():void { var results:Vector.<NetworkInterface> = NetworkInfo.networkInfo.findInterfaces(); for (var i:int=0; i<results.length; i++) { var output = output + "Name: " + results[i].name + "\n" + "DisplayName: " + results[i].displayName + "\n" + "MTU: " + results[i].mtu + "\n" + "HardwareAddr: " + results[i].hardwareAddress + "\n" + "Active: " + results[i].active + "\n"; for (var j:int=0; j<results[i].addresses.length; j++) { output = output + "Addr: " + results[i].addresses[j].address + "\n" + "Broadcast: " + results[i].addresses[j].broadcast + "\n" + "PrefixLength: " + results[i].addresses[j].prefixLength + "\n" + "IPVersion: " + results[i].addresses[j].ipVersion + "\n"; } output = output + "\n"; } }

If you run this example on an Apple MacBook Pro, you will get a list of interfaces that minimally contains en0 and en1; for example:

Name: en0 DisplayName: MTU: 1500 HardwareAddr: 00:25:00:a5:35:1e Active: true Addr: 2001:1890:110b:1498:225:ff:fea5:351e Broadcast: PrefixLength: 64 IPVersion: IPv6 Addr: 153.32.154.241 Broadcast: 153.32.155.255 PrefixLength: 22 IPVersion: IPv4 Name: en1 DisplayName: MTU: 1500 HardwareAddr: 00:23:6c:96:ab:c1 Active: true Addr: 10.4.217.218 Broadcast: 10.4.219.255 PrefixLength: 22 IPVersion: IPv4

The network change event

Another useful feature of the NetworkInfo class is the ability to detect network changes. A network change event occurs when a network interface becomes enabled or disabled.

For example, an application may use the NetworkInfo class to obtain a list of currently available network interfaces and select the best candidate interface from that list. Later, if another interface becomes enabled, the application will be notified via a network change event. It can then use that opportunity to determine if the recently enabled interface is a better candidate and reestablish the network connection using the new interface.

Similarly, if an interface becomes disabled or disconnected from the network, the application will receive a network change event, enabling it to take the appropriate action. For example, it may terminate the connection or select another interface and reestablish the connection.

The network change event is fired from the NativeApplication class and bubbled up by the NetworkInfo class. To receive network change events, an application must add an event listener:

NetworkInfo.networkInfo.addEventListener(Event.NETWORK_CHANGE, onNetworkChange);

Alternatively, you can add the event listener on your NativeApplication object:

NativeApplication.nativeApplication.addEventListener(Event.NETWORK_CHANGE, onNetworkChange);

Where to go from here

For further information about the NetworkInfo class and its usage, please refer to the AIR 2 release notes.

More Like This

  • Using the Microphone capabilities in Adobe AIR 2
  • Reducing CPU usage in Adobe AIR
  • Using drag-and-drop support of remote files in Adobe AIR 2
  • Resolving DNS records in Adobe AIR 2
  • Using the Adobe AIR 2 NativeProcess API to create a screen recorder
  • Exploring the new file capabilities in Adobe AIR 2
  • Creating a socket server in Adobe AIR 2
  • Customer story: AIR - NASDAQ Market Replay
  • User experience considerations with SQLite operations
  • Creating accessible Adobe AIR applications with the Flex SDK

Tutorials & Samples

Tutorials

  • Retrieving a list of network interfaces in Adobe AIR 2
  • Writing multiscreen AIR apps
  • Using the AIR 2 NativeProcess API to create a screen recorder
  • Resolving DNS records in Adobe AIR 2

Samples

  • Using the Salesbuilder Adobe AIR sample application

Adobe AIR Forums

More
04/11/2012 Surround sound 5.1 with Air 3.2 on desktop app?
12/12/2011 Live Streaming H.264 Video on iOS using AIR
04/17/2012 HTMLLoader - Google Maps?
04/12/2012 Tabindex in forms on mobile?

Adobe AIR Blog

More
07/09/2012 Protected: Publishing Adobe AIR 3.0 for TV on Reference Devices
07/08/2012 Source Code: Adobe AIR 3.3 Retina Video Application
07/06/2012 Application specific File Storage on Adobe AIR based ios Application
07/04/2012 Recent Work - iPad/Android App: Inside My toyota

Products

  • Acrobat
  • Creative Cloud
  • Creative Suite
  • Digital Marketing Suite
  • Digital Publishing Suite
  • Elements
  • Mobile Apps
  • Photoshop
  • Touch Apps
  • Student and Teacher Editions

Solutions

  • Digital marketing
  • Digital media
  • Web Experience Management

Industries

  • Education
  • Financial services
  • Government

Help

  • Product help centers
  • Orders and returns
  • Downloading and installing
  • My Adobe

Learning

  • Adobe Developer Connection
  • Adobe TV
  • Training and certification
  • Forums
  • Design Center

Ways to buy

  • For personal and home office
  • For students, educators, and staff
  • For small and medium businesses
  • For businesses, schools, and government
  • Special offers

Downloads

  • Adobe Reader
  • Adobe Flash Player
  • Adobe AIR
  • Adobe Shockwave Player

Company

  • News room
  • Partner programs
  • Corporate social responsibility
  • Career opportunities
  • Investor Relations
  • Events
  • Legal
  • Security
  • Contact Adobe
Choose your region United States (Change)
Choose your region Close

North America

Europe, Middle East and Africa

Asia Pacific

  • Canada - English
  • Canada - Français
  • Latinoamérica
  • México
  • United States

South America

  • Brasil
  • Africa - English
  • Österreich - Deutsch
  • Belgium - English
  • Belgique - Français
  • België - Nederlands
  • България
  • Hrvatska
  • Česká republika
  • Danmark
  • Eastern Europe - English
  • Eesti
  • Suomi
  • France
  • Deutschland
  • Magyarország
  • Ireland
  • Israel - English
  • ישראל - עברית
  • Italia
  • Latvija
  • Lietuva
  • Luxembourg - Deutsch
  • Luxembourg - English
  • Luxembourg - Français
  • الشرق الأوسط وشمال أفريقيا - اللغة العربية
  • Middle East and North Africa - English
  • Moyen-Orient et Afrique du Nord - Français
  • Nederland
  • Norge
  • Polska
  • Portugal
  • România
  • Россия
  • Srbija
  • Slovensko
  • Slovenija
  • España
  • Sverige
  • Schweiz - Deutsch
  • Suisse - Français
  • Svizzera - Italiano
  • Türkiye
  • Україна
  • United Kingdom
  • Australia
  • 中国
  • 中國香港特別行政區
  • Hong Kong S.A.R. of China
  • India - English
  • 日本
  • 한국
  • New Zealand
  • 台灣

Southeast Asia

  • Includes Indonesia, Malaysia, Philippines, Singapore, Thailand, and Vietnam - English

Copyright © 2012 Adobe Systems Incorporated. All rights reserved.

Terms of Use | Privacy Policy and Cookies (Updated)

Ad Choices

Reviewed by TRUSTe: site privacy statement