From C# to Android via Socket. Can't find my mistake
<p>The problem - I can't get this functions working. I see in LogCat that socket is connected to c# server, but I don't see received data. What I'm doing wrong?</p>

<p>Here is c# function with MessageBoxes for checking:</p>

<pre><code>private void receiveConnection(){
        Socket myHandler = null;
        bool isConnected = false;
        while (true)
        {
            if (!isConnected)
            {
                myHandler = wSocket.Accept();
                isConnected = true;
                MessageBox.Show("We have client!");
            }

            if (sendDataToAndroid)
            {  
                try
                {
                    sendDataToAndroid = false;   
                    NetworkStream stream = new NetworkStream(myHandler);
                    StreamWriter sw = new StreamWriter(stream);

                    string myMsg = "";
                    myMsg += temp_F.Length + " ";

                    temp_F[0] = 3.151F;
                    temp_F[1] = 1.415F;
                    temp_F[2] = 5.572F;
                    temp_F[3] = 6.320F;

                    for (int i = 0; i &lt; temp_F.Length; i++)
                    {
                        myMsg += temp_F[i] + " ";
                    }
                    byte[] msg = Encoding.ASCII.GetBytes(myMsg);

                    MessageBox.Show("Data to send: " + myMsg);

                    try
                    {
                        myHandler.Send(msg);
                        MessageBox.Show("Data has been sent!");
                    }
                    catch (Exception e) {
                        MessageBox.Show("Error while sending data!");
                    }
                }

                catch (Exception e)
                {
                    isConnected = false;
                    myHandler.Close();
                    myHandler = null;
                    MessageBox.Show("Error while sending data...");
                }
            }
        } 
    }
</code></pre>

<p>And here is Android function which is always trying to receive data:</p>

<pre><code>public class SendThread implements Runnable {
    public void run() 
    {
        Socket socket = null;
        BufferedReader in = null;

        while (true)
        {
            // Loop until connected to server
            while (socket == null){
                try{
                    socket = new Socket ("192.168.137.1", 808);
                }
                catch (Exception e) {
                    socket = null;
                }
            }

            // Get from the server   
            try {
                Log.d("Connection: ", "connected");
                in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
                String line = null;


                while ((line = in.readLine()) != null) {
                    Log.d("Socket:", line);

                    NumberFormat nf = new DecimalFormat ("990,0");

                    String[] tokens = line.split(" ");

                    int currTempSize = Integer.parseInt(tokens[0]);
                    currentTemp = new double[currTempSize];

                    for (int i = 0; i &lt; currTempSize; i++)
                        currentTemp[i] = (Double) nf.parse(tokens[i+1]);

                    //Toast.makeText(getApplicationContext(), "Received data:", duration)
                    for (int i = 0; i &lt; currTempSize; i++){
                        Log.d("Converted data: currentTemp["+i+"] = ", currentTemp[i]+"");
                    }
                }
            } 
            catch (Exception e) {
                    socket = null;
                    in = null;
                    Log.d("Connection: ", "lost.");
            }
        }
    }
}
</code></pre>
