Note that there are some explanatory texts on larger screens.

plurals
  1. POHandle http fired by Flex in C# server
    primarykey
    data
    text
    <p>Hi I am trying to send a simple HTTP message from Flex to C# server, but it seems that I am getting tow calls, first is the real one and the second is an empty one.</p> <p>Why is that and how can I handle it?</p> <p>This is my C# code:</p> <pre><code>TcpListener listener = new TcpListener(IPAddress.Any, 9400); listener.Start(); Console.WriteLine("Server started"); Socket client; while (true) { client = listener.AcceptSocket(); // client.Available is an expensive call so it's just for testing Console.WriteLine("Client accepted " + client.Connected + " " + client.Available); SocketHandler handler = new SocketHandler(); ThreadPool.QueueUserWorkItem(handler.handleSocket, client); } </code></pre> <p>this is the SocketHandler:</p> <pre><code>public void handleSocket(object socketObjeck) { try { socket = (Socket)socketObjeck; byte[] buffer = new byte[1024]; SocketSettings.setSocket(socket); //blocker... try { socket.Receive(buffer); } catch (Exception e) { Console.WriteLine("Error\nFaild reading from socket\n" + e.Message); socket.Close(); return; } parseData(buffer); socket.Close(3); } catch (Exception e) { Console.WriteLine("Error\nError \n" + e.Message + "\n" + e.StackTrace); } } </code></pre> <p>And this is my flex code:</p> <pre><code>var request:URLRequest = new URLRequest(); request.data = "Hello from flex"; request.url = URL; request.method = URLRequestMethod.POST; loader.load(request); </code></pre> <p>I am always getting 2 calls. The line:</p> <pre><code>Console.WriteLine("Client accepted " + client.Connected + " " + client.Available); </code></pre> <p>called twice. What am I missing?</p> <p><strong>Edit 1:</strong> I can tell you for sure that the second call is empty, it's not even seen in chrome JavaScript console, it's like flex opening a connection, and waiting for some response or I don't know what... but it sending no data.</p> <p><strong>Edit 2:</strong></p> <p>I been trying to send a true HTTP response a notice another thing, the second call is coming without waiting for the first call, if I am putting the response thread to short sleep(100 milliseconds in my test) then I am getting the second call before I been able to response for the first one.</p> <p>P.S Using Flex 4.6, Visual Studio 2010</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload