アドビ
製品

トップ

  • Adobe Creative Cloud
  • Creative Cloudグループ版
  • Creative Suite 6
  • Adobe Marketing Cloud
  • Acrobat
  • Photoshop
  • SiteCatalyst

教育向け

  • 学生・教職員個人向け
  • 小・中・高等学校機関
  • 高等教育機関

Adobe Creative Cloud

  • Adobe Creative Cloudとは?

デザインと写真処理

  • Photoshop
  • Illustrator
  • InDesign
  • Adobe Muse
  • Lightroom
  • Elementsファミリー

ビデオ

  • Adobe Premiere Pro
  • After Effects

Web開発&HTML5

  • Edgeツール&サービス [新規ウィンドウで開く]
  • Dreamweaver
  • ゲーム [新規ウィンドウで開く]
  • モバイルアプリ

Adobe Marketing Cloud

  • Adobe Marketing Cloudとは?
  • 分析
  • Webエクスペリエンスマネジメント
  • 広告管理
  • テストとターゲティング
  • ソーシャルマーケティング

Analytics

  • SiteCatalyst
  • Adobe Discover
  • Insight

Target

  • Test&Target
  • Recommendations

Social

  • Adobe Social

Experience Manager

  • CQ
  • Scene7

Meida Manager

  • AdLens

ドキュメントサービス

  • Acrobat
  • FormsCentral [新規ウィンドウで開く]
  • SendNow [新規ウィンドウで開く]
  • Acrobat.com [新規ウィンドウで開く]

パブリッシング

  • Digital Publishing Suite

  • すべての製品を見る
ビジネスソリューション

Digital Media

  • Creative Cloudグループ版
  • ユーザー事例
  • Digital Media事例

ビジネスニーズ別

  • 分析
  • デジタルパブリッシング
  • ドキュメント管理
  • 広告管理
  • ソーシャルマーケティング
  • テストとターゲティング
  • ビデオ編集と公開
  • Web開発 [新規ウィンドウで開く]
  • Webエクスペリエンスマネジメント
  • すべてのビジネスニーズを見る

Digital Marketing

  • Adobe Marketing Cloud
  •  
  • Digital Marekting事例

業種別

  • 放送業界
  • 教育機関
  • 金融機関
  • 行政機関
  • 出版
  • 小売
  • 全業種を見る
サポートとラーニング

サポート

  • サポートホーム
  • サポートプログラム
  • 製品ヘルプ
  • ダウンロードとインストールヘルプ
  • Adobe Creative Cloud メンバーシップサポート
  • サポートお問い合わせ

ラーニング

  • ラーニングとチュートリアル
  • マーケター向けトレーニングサービス [新規ウィンドウで開く]
  • Photoshopマガジン
  • デザインマガジン
  • Focus In(ビデオ制作者向け)
  • Adobe Developer Connection
  • アトリエ(初心者向け写真編集)
  • Adobe Marketing Center
  • Adobe Marketing Cloud Japan Blog [新規ウィンドウで開く]
  • 認定制度
ダウンロード
  • 体験版
  • Adobe Flash Player
  • Adobe Reader
  • Adobe AIR
  • すべてのダウンロードを見る
会社情報
  • 採用情報
  • 投資家の皆様へ(英語)
  • プレスルーム
  • プライバシー
  • 企業の社会的責任(CSR)
  • ショーケース
  • お問い合わせ
  • その他の会社情報
ご購入
  • 個人・プロフェッショナル向け製品
  • 学生・教職員向け製品
  • 小中規模ビジネス向け製品
  • ライセンスについて
  • キャンペーン情報
  • Adobe Marketing Cloudお問合せ [新規ウィンドウで開く]
  • 販売パートナー
検索
 
情報 サインイン
サインインの目的 お客様のアカウントや体験版ダウンロード、製品の拡張機能、コミュニティエリアへのアクセスなどを管理するため
ようこそ、さん
My Adobe
注文状況
ユーザー情報
マイアカウント
製品およびサービスの登録状況
サインアウト
カート
プライバシー My Adobe
アドビ
製品 セクション 購入   検索  
ソリューション会社情報
サポートラーニング
サインイン サインアウト プライバシー My Adobe
先行予約の提供開始予定日Date. 商品が発送されるまで、クレジットカードには課金されません。提供開始の予定日は変更される場合があります。 先行予約の提供開始予定日Date. ダウンロードの準備が整うまで、クレジットカードには課金されません。提供開始の予定日は変更される場合があります。
個数:
(消費税を含む )
ご購入には学生・教職員個人版の購入資格の確認が必要です。
小計 (税込)
キャンペーン ( 税込)
送料( 税込)
消費税
Calculated at checkout
合計 ( 税込)
カートの中身を見る
Adobe Developer Connection [ADC] / Adobe AIR デベロッパーセンター /

Creating a socket server in Adobe AIR 2

著者 Christian Cantrell

Christian Cantrell
  • blogs.adobe.com/cantrell

Created

17 November 2009

ページ ツール

Facebookでシェア
Twitterでツイート
LinkedInでシェア
ブックマーク
印刷

この記事に設定されたタグ

ActionScriptAdobe AIRFlexnetworkingsocket

必要条件

この記事に必要な予備知識

This article is intended for developers who are comfortable with ActionScript 3 and who have at least a basic understanding of TCP sockets.

ユーザーレベル

中級

必要な製品

  • Adobe AIR

This article discusses the new socket server support in AIR 2. The ability to listen on a socket means that your AIR 2 applications can send and receive data over a TCP socket without having to initiate the socket connection. Being able to accept incoming socket connections never made much sense for SWF content running in the browser, but in the context of desktop applications written for Adobe AIR, it opens up all kinds of new possibilities.

This article covers the following topics:

  • The history of socket support in Flash Player
  • Introducing the SocketServer class
  • Tips on using the ServerSocket class
  • Sample application: HTTPeek

History of socket support in Flash Player

Flash Player has a long history of support for TCP sockets. The XMLSocket was first introduced in Flash Player 5. XMLSockets provide developers with an easy way to read and write XML data between a client and a server across a TCP connection. In Flash Player 9, after watching developers use the XMLSocket class to read and write all kinds of other data besides just XML, the Socket class was introduced.

The Socket class (along with ByteArrays) gives Flash developers true binary socket support, which enables them to pass data between clients and servers using protocols other than HTTP. When the Flash Platform was extended to the desktop with Adobe AIR, developers started asking for the ability to create socket endpoints so as to be able to listen on sockets. AIR 2 delivers this capability with the ServerSocket class.

Introducing the ServerSocket class

The ServerSocket class enables developers to accept incoming socket connections, as opposed to just being able to open connections from clients. In other words, using the ServerSocket class enables applications to actually become servers. Establishing a socket endpoint has several interesting use cases:

  • Inter-application communication: Applications can communicate with each other by listening on sockets, connecting to each other, and passing data back and forth.
  • Peer-to-peer applications: It's becoming increasingly useful for applications to be able to share data with each other across networks, as opposed to just with servers.
  • Additional protocol support: Protocols such as FTP may require clients to listen on specific ports so the server can connect back to the client (as in the case of active mode).
  • Network utilities: Applications like proxy servers require the use of both incoming and outgoing socket connections.

Creating a socket endpoint is as easy as creating an outgoing socket. The following code shows how to listen for incoming TCP connections:

import flash.net.ServerSocket; import flash.events.ServerSocketConnectEvent; private function onConnect(e:ServerSocketConnectEvent):void { var incomingSocket:Socket = e.socket; // You can now read and write data from the socket instance } var server:ServerSocket = new ServerSocket(); server.addEventListener(Event.CONNECT, onConnect); server.bind(8888); // Pass in the port number you want to listen on server.listen();

Tips on using the ServerSocket class

Keep in mind the following if you want your application to act as a server:

  • For security reasons, the ServerSocket class can only be used in the application sandbox.
  • Applications that attempt to bind to ports below 1024 will be subject to the operating system's security policy. On Mac OS X and Linux, these applications will need to run as root. For this reason, it's best for most applications to use nonprivileged ports.
  • The ServerSocket constructor takes a backlog argument. If not provided or set to 0 (zero), the backlog is the maximum value supported by the operating system.

HTTPeek: An AIR 2 HTTP proxy server

HTTPeek, shown in Figure 1, is a sample application I wrote to demonstrate the use of the ServerSocket class. It's an HTTP proxy which logs request and response headers of all HTTP traffic proxied through it, and is useful for debugging web applications. You can download the source code from Google Code or the AIR Developer Center.

The HTTPeek application
Figure 1. The HTTPeek application

Where to go from here

This article covered basic information about listening for incoming TCP sockets in Adobe AIR 2. For more information on using sockets in Flash Player, see:

  • Demonstration of the ServerSocket API in AIR
  • HTTPeek sample application on Google Code or the AIR Developer Center

Creative Commons License
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License

More Like This

  • Retrieving a list of network interfaces in Adobe AIR 2
  • Using the Microphone capabilities in Adobe AIR 2
  • User experience considerations with SQLite operations
  • Using the Adobe AIR 2 NativeProcess API to create a screen recorder
  • Using the Salesbuilder sample application
  • Using the SQLite database access API in Adobe AIR
  • Using the Salesbuilder Adobe AIR sample application
  • Writing multiscreen AIR apps
  • Resolving DNS records in Adobe AIR 2
  • Building an XML viewer on Adobe AIR with Flex

製品

  • Adobe Creative Cloud
  • Creative Cloudグループ版
  • Creative Suite
  • Adobe Marketing Cloud
  • Acrobat
  • Photoshop
  • Digital Publishing Suite
  • Elementsファミリー
  • SiteCatalyst
  • 教育向け

ダウンロード

  • 体験版
  • Adobe Reader
  • Adobe Flash Player
  • Adobe AIR

サポート

  • ヘルプ&サポート
  • 注文と返品
  • ダウンロードに関するヘルプ
  • ユーザー登録に関するヘルプ

ラーニング

  • トレーニング
  • Adobe TV
  • デザインマガジン
  • Photoshopマガジン
  • Focus In(ビデオ制作者向け)
  • Adobe Developer Connection [ADC]
  • 初心者向け写真編集
  • Adobe Marketing Cloud Japan Blog

ご購入

  • 個人・プロフェッショナル向け製品
  • 学生・教職員向け製品
  • 小中規模ビジネス向け製品
  • ライセンスについて
  • キャンペーン情報
  • 販売パートナー

会社情報

  • プレスルーム
  • パートナープログラム
  • 企業の社会的責任(CSR)
  • 採用情報
  • 投資家の皆様へ(英語)
  • イベント
  • 法的事項
  • セキュリティ
  • お問い合わせ
地域を選択してください 日本(変更)
地域を選択してください 閉じる

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 © 2013 Adobe Systems Software Ireland Ltd. All rights reserved.

利用条件 | プライバシー | Cookie

Reviewed by TRUSTe: site privacy statement