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 6624133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:36:57+00:00 2026-05-25T21:36:57+00:00

I have created a flex app that uses sockets. I published the flex app

  • 0

I have created a flex app that uses sockets. I published the flex app in a web application that runs on glassfish server.
Now from that flex app i create a socket connection to a C# server and start sending/receiving data.
The problem is that after i create the socket connection to C# server the flex app first checks the policy file, and after it get’s it, it closes the socket, without keep the connection alive.

This is my C# server:

TcpListener tcpListener = new TcpListener(IPAddress.Parse("172.17.41.211"), 12345);
TcpClient tcpclient = tcpListener.AcceptTcpClient();

Socket client = tcpclient.Client;
while (client.Available > 0)
{
   int bytes = 0;
   byte[] m_aBuffer = new byte[1024];
   bytes = client.Receive(m_aBuffer, m_aBuffer.Length, SocketFlags.None);
   String str = Encoding.ASCII.GetString(m_aBuffer, 0, bytes);
   if (str.StartsWith("<policy-file-request/>"))
   {
      sendBytes = Encoding.ASCII.GetBytes("<cross-domain-policy><allow-access-from domain=\"172.17.41.211\" to-ports=\"12345\"/></cross-domain-policy>\0");
      client.Send(sendBytes);
   }
}

while (client.Connected)
{
   Thread.Sleep(200);
   sendBytes = Encoding.ASCII.GetBytes("message to client");
   client.Send(sendBytes, sendBytes.Length, SocketFlags.None);
}

Now the flex client looks like:

private var socket:Socket = new Socket();
socket.addEventListener(Event.CONNECT, onConnect);
socket.addEventListener(Event.CLOSE, onClose);
socket.addEventListener(ProgressEvent.SOCKET_DATA, onData);
socket.addEventListener(ErrorEvent.ERROR, errorHandler);
socket.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, errorHandler);
...
socket.connect("172.17.41.211", 12345);    
...

Now after i create the connection and it gets the policy from server it closes this socket, so to be able to use this connection i have to call again

socket.connect("172.17.41.211", 12345));

After i do this, i can use normally the connection.

Can someone suggest why this happens and maybe is possible to not have closed the connection ?

  • 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-25T21:36:57+00:00Added an answer on May 25, 2026 at 9:36 pm

    You don’t send the policy file through the socket itself. It needs to be on a different channel. For instance, if you connect to some ip/port, by default flash will try to connect to the same ip but on port 843 and look for the master policy file.

    You can also set it manually using Security.loadPolicyFile(someURL). More information can be found here.

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

Sidebar

Related Questions

I have a Flex/Java web application that uses Maven as a build tool. Currently,
I have a Flex application that builds and runs from Eclipse without any problems.
I have created a flex web application with php server side support. There is
I have created an ashx handler that returns an image to my flex app.
I have created one application in flex that is accessing the Java webservice using
I have created an application using Adobe Flex. I took all the files from
I have this flex app (it's a flex project created from flash builder), and
I have Flex/AIR app that connects to a tomcat server via BlazeDS. I'm not
I have created an API in AS3 that uses Flex bindings. The API is
Can I create an application with Flex Builder Trial ( that I have just

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.