C2DM, IOException when sending message
<p>I can't get the sending part of C2DM to work. I get IOException at OutputStream out = conn.getOutputStream();</p>

<pre><code>public void sendMessage() throws IOException{       
                String key = readFileAsString("acct/"+to+"/key");

                StringBuilder postDataBuilder = new StringBuilder();
                postDataBuilder.append("registration_id").append("=").append(key);
                postDataBuilder.append("&amp;").append("collapse_key").append("=").append("0");
                postDataBuilder.append("&amp;").append("data.payload").append("=").append(URLEncoder.encode(to+"--"+"acct/"+to+"/1", UTF8));
                byte[] postData = postDataBuilder.toString().getBytes(UTF8);

                URL url = new URL("https://android.apis.google.com/c2dm/send");

                HttpURLConnection conn = (HttpURLConnection) url.openConnection();
                conn.setDoOutput(true);
                conn.setUseCaches(false);
                conn.setRequestMethod("POST");
                conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
                conn.setRequestProperty("Content-Length", Integer.toString(postData.length));                   
                conn.setRequestProperty("Authorization", "GoogleLogin auth=" + cl);

             //------------------
                OutputStream out = conn.getOutputStream();
             //--------------------------
                out.write(postData);
                out.close();

                int sw =conn.getResponseCode();
                System.out.println(""+sw);
                switch (sw) {
                    case 200:
                        System.out.println("Success, but check for errors in the body");
                        break;
                    case 503:
                        System.out.println("Service unavailable");
                        break;
                    case 401:
                        System.out.println(" Invalid authentication token");
                        break;
                 }

            }
</code></pre>

<p>Thank you!</p>
