c#与JAVA通信 程序windows上运行正常,但在mobile5.0 ppc上运行不了
客户端发送请求和接收:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Net;
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create("http://192.168.1.10:8080/work/test");
webRequest.Method = "post";
Stream reqStream = webRequest.GetRequestStream();
int x = Int32.Parse(textBox1.Text);
int m = IPAddress.HostToNetworkOrder(x);
byte[] temp = BitConverter.GetBytes(m);
reqStream.Write(temp, 0, temp.Length);
reqStream.Close();
HttpWebResponse myResponse = (HttpWebResponse)webRequest.GetResponse();
StreamReader sr = new StreamReader(myResponse.GetResponseStream());
byte[] readBuff = new byte[1024];
sr.BaseStream.Read(readBuff1, 0, 2);
int count2 = BitConverter.ToInt16(readBuff1, 0);
int count22 = IPAddress.NetworkToHostOrder(count2);
content1 = count22.ToString();
MessageBox.Show(content1);
(服务端java写的接收一个int并发送回来一个int);
客户端在windows xp(有装vs2005)下可以正常通信,但在mobile 5.0 PPC下提示SendChunked要为true或content要设长度;
后加webRequest.SendChunked=true后在windows xp下正常,但在PPC模拟器下不提示服务器501错误。