Hi everyone,

I have a problem for my new application on Windows Phone 7 & 8. I have a server on C# which create a socket listener and I want my Windows Phone app and my Windows 8 app connect to it to transfert some data between them.

My connection with my W8 app works, but the WP8 app throw a System.Net.Sockets.SocketError.ConnectionRefused.

I want to try on Windows Phone 7 but there are "no connection" so I have to try my app on my Lumia 800, but I think it will be the same error.

This is my code for the server C#:

Code:
 private void StartListener()
        {
            _listenerThread = new Thread(RunListener);
            _listenerThread.Start();
        }

        private void RunListener()
        {
            _listener = new TcpListener(IPAddress.Any, 12350);
            _listener.Start();

            while(true)
            {
                try
                {
                    TcpClient client = _listener.AcceptTcpClient();
                }
                catch (Exception) { }
            }
        }
Now the Windows Phone app:
Code:
           string result = string.Empty;
            IPAddress address = string.Empty;

            address = IPAddress.Parse("127.0.0.1");

            IPEndPoint endPoint = new IPEndPoint(address, 12350);

            // Create a stream-based, TCP socket using the InterNetwork Address Family. 
            _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            // Create a SocketAsyncEventArgs object to be used in the connection request
            SocketAsyncEventArgs socketEventArg = new SocketAsyncEventArgs();
            socketEventArg.RemoteEndPoint = endPoint;

            // Inline event handler for the Completed event.
            socketEventArg.Completed += new EventHandler<SocketAsyncEventArgs>(delegate(object s, SocketAsyncEventArgs e)
            {
                // Retrieve the result of this request
                result = e.SocketError.ToString(); 

               // ------------------------------------------------------                            result equal to ConnectionRefused                      --------------------------------------------

                // Signal that the request is complete, unblocking the UI thread
                _clientDone.Set();
            });

            // Sets the state of the event to nonsignaled, causing threads to block
            _clientDone.Reset();

            // Make an asynchronous Connect request over the socket
            _socket.ConnectAsync(socketEventArg);

            // Block the UI thread for a maximum of TIMEOUT_MILLISECONDS milliseconds.
            // If no response comes back within this time then proceed
            _clientDone.WaitOne(TIMEOUT_MILLISECONDS);

            return result;
        }
An idea of what the problem is?

Thanks in advance.