问题描述
有个LBS的项目发给我的DEMO是JAVA的代码如下:Stringoutput="<olxdir="up"version="0.0.1"compress="false"><client></client><functionname="GAS.AUTH_LOGIN"seq="4"synchronized="true"timeout="30"needreturn="true"paramencrypt="none"><param><tree-objectversion="0.0.2"><valuekey="authId"class="bstr"value="aHRnbGFkbWlu"></value><valuekey="authIdType"class="str"value="LOGIN_NAME"></value><valuekey="authIdCodec"class="str"value="NONE"></value><valuekey="authPwd"class="bytes"value="MXRIU3RRWlZxV1NCQzZWWkxKSUFwUT09"></value><valuekey="authPwdCodec"class="str"value="NONE"></value><valuekey="returnEntity"class="bool"value="true"></value><valuekey="tcode"class="str"value="00"></value></tree-object></param></function></olx>";try{Socketsocket=newSocket("211.138.196.249",6666);PrintWriterpw=newPrintWriter(socket.getOutputStream());pw.println(output);pw.flush();BufferedReaderbr=newBufferedReader(newInputStreamReader(socket.getInputStream()));Stringinput=br.readLine();System.out.println(input);pw.close();br.close();socket.close();}catch(UnknownHostExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();}catch(IOExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();}
我写的c#代码stringmessage="<olxdir="up"version="0.0.1"compress="false"><client></client><functionname="GAS.AUTH_LOGIN"seq="4"synchronized="true"timeout="30"needreturn="true"paramencrypt="none"><param><tree-objectversion="0.0.2"><valuekey="authId"class="bstr"value=""+username+""></value><valuekey="authIdType"class="str"value="LOGIN_NAME"></value><valuekey="authIdCodec"class="str"value="NONE"></value><valuekey="authPwd"class="bytes"value=""+password+""></value><valuekey="authPwdCodec"class="str"value="NONE"></value><valuekey="returnEntity"class="bool"value="true"></value><valuekey="tcode"class="str"value="00"></value></tree-object></param></function></olx>";intport=6666;stringip="211.138.196.249";IPAddressserverIp=IPAddress.Parse(ip);intserverPort=Convert.ToInt32(port);IPEndPointiep=newIPEndPoint(serverIp,serverPort);Socketsocket=newSocket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);socket.Connect(iep);IPEndPointtempRemoteIP=(IPEndPoint)socket.LocalEndPoint;Response.Write("端口:"+tempRemoteIP.Port.ToString()+"正在监听......");Response.Write("与远程计算机"+ip+":"+port+"建立连接!");byte[]byteMessage=Encoding.Default.GetBytes(message);socket.Send(byteMessage);Response.Write("正在等待接收信息...");byte[]bytes=newbyte[1024];intrecvbytes=socket.Receive(bytes);stringstrmsg=Encoding.Default.GetString(bytes);socket.Close();
执行到socket.Receive(bytes);就没发执行下午求救呀
解决方案
解决方案二:
急救呀