上面有点问题!C# code    String url = "http://www.google.com/glm/mmap";
                HttpWebRequest req =(HttpWebRequest)WebRequest.Create(new Uri(url));  //这里是取得创建一个请求吧..但是还没有请求?请问是不是!
                req.Method = "POST";
                int LAC = Convert.ToInt32("123");
                int CID = Convert.ToInt32("321");
                byte[] pd ={ 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 102, 114, 0, 18,
83, 111, 110, 121, 95, 69, 114, 105, 99, 115, 115, 111, 110,
45, 75, 55, 53, 48, 0, 5, 49, 46, 51, 46, 49, 0, 3, 87, 101,
98, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0,
184, 18, 0, 0, 65, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0 }
              req.ContentLength = pd.Length;
                req.ContentType = "application/binary";
                req.GetRequestStream().Write(pd, 0, pd.Length);主要问题..这里是创建的一个socket请求还是http请求啊??我看大到method='post',但是又没有看到argsName,                //这里的程序是连接上面程序的...是可以运行的.!
               C# code    HttpWebResponse res =
                (HttpWebResponse)req.GetResponse();
                byte[] ps = new byte[res.ContentLength];
                res.GetResponseStream().Read(ps, 0, ps.Length);
                Console.WriteLine("LAC {0}, CID {1}", LAC, CID);

解决方案 »

  1.   

    String url = "http://www.google.com/glm/mmap";
    HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
    conn.setRequestMethod("POST");
    conn.setDoOutput(true);
    conn.setRequestProperty("ContentType", "application/binary");
    byte[] pd ={ 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 102, 114, 0, 18,
    83, 111, 110, 121, 95, 69, 114, 105, 99, 115, 115, 111, 110,
    45, 75, 55, 53, 48, 0, 5, 49, 46, 51, 46, 49, 0, 3, 87, 101,
    98, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0,
    (byte) 184, 18, 0, 0, 65, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0 };
    conn.setRequestProperty("ContentLength", Integer.toString(pd.length));
    conn.getOutputStream().write(pd);
      

  2.   

    3楼的朋友,
    在java中
    如果byte的值大于  127?
    可以直接通过  (byte)number来转???比如  (byte)184?是正确?