Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5951615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:33:46+00:00 2026-05-22T17:33:46+00:00

I have a Flex AIR app, and i am trying to get data from

  • 0

I have a Flex AIR app, and i am trying to get data from a Java Server. Can some one tell me if this approach will work?

Start a ServerSocket in Java and wait for a connection.
Use Flex to connect to the same port.
Write some data to the socket from Java Server.
Read the data at the Flex end and process it.

—
Update :
I think i am able to get this working, but the data that i read back at Flex end seems to be empty.

My server code is :

        socket  = new ServerSocket(port);
        client  = socket.accept();

        InetAddress address = client.getInetAddress();           

        BufferedReader in = new BufferedReader( new InputStreamReader(
                client.getInputStream()));
        PrintWriter out = new PrintWriter(client.getOutputStream());            

        out.println("hi");
        out.flush();

And my code in Flex is

        private function onRecieveDataClick():void
        {
            var host:String = "127.0.0.1";
            var port:int = 9090;

            var socket:Socket = new Socket();
            socket.endian = Endian.BIG_ENDIAN;
            socket.addEventListener(Event.CONNECT, onConnect);
            socket.connect(host, port);
        }

        private function onConnect(event:Event):void
        {
            trace(" Connected to server socket ");
            var socket:Socket = Socket(event.target);
            var obj:String = socket.readUTFBytes( socket.bytesAvailable);
            trace(obj);
        }

My current problem is socket.bytesAvailable becoming 0 and therefore obj is coming up as “”. So how to read data sent from the server using a Socket in Flex?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:33:46+00:00Added an answer on May 22, 2026 at 5:33 pm

    After some basic googling, I’ve found a blog post that does exactly what you are describing:
    http://arthurnn.com/blog/2010/12/09/socket-connection-beteween-flex-air-and-java/

    The example however runs the java app on the localhost, not remotely like you describe.
    Therefore it might occur that you will encounter some sandbox violations when trying to connect to the remote server socket. This might be solved by adding a crossdomain.xml to the root of java app server.

    In fact, this blog post is a rudimentary example of what merapi does under the hood.

    Cheers

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can a Flex Air Android app have transparent background, like the Android Theme.Transluscent? I've
I have an air app that collects live data from a user's action and
I have an AIR/Flex app that can have multiple windows (s:Window instances) open at
I have some shared code between an Adobe AIR App and an Adobe Flex
I have Flex/AIR app that connects to a tomcat server via BlazeDS. I'm not
I have an AIR app initially written in Flex 3 that I had removed
I have an AIR/Flex app I made, I have a few people testing it
We have a air/flex app that we want to add an effect to. Basically
I have a simple little test app written in Flex 3 (MXML and some
I have no experience with Adobe Air/Flex and want to know, are there some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.