How to use 'Curl' in php to send data to android
<p>I have a listener in an android application to detect messages sent by the server php</p>

<pre><code> public class Threa implements Runnable

{
   public static final String SERVERIP = "192.168.1.4";
    public static final int SERVERPORT =6060 ; //4444
    public BufferedReader in;
    public int x=0;
      public void run() {

             try {

                 ServerSocket serverSocket = new ServerSocket(SERVERPORT);

                 while (true)
                     {
                     x++;

                      Socket client = serverSocket.accept();
                     try {

                  in = new BufferedReader(new InputStreamReader(client.getInputStream()));

                          String str = in.readLine();

                        } catch(Exception e) {


                        } finally {
                            client.close();

                                }
                 }

             } catch (Exception e) {

                     }
        }

    }
</code></pre>

<p>I found this code on the Internet</p>

<pre><code>function get_url($url) 
    {
        $ch = curl_init();

        if($ch === false)
        {
            die('Failed to create curl object');
        }

        $timeout = 5;
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
        $data = curl_exec($ch);
        curl_close($ch);
        return $data;
    }

    echo get_url('http://www.apple.com/');
</code></pre>

<p>using cURL in php to send the message is correct, if not what is the solution to solve this problem, please give  me an idea </p>
