求助,关于socket通信,用UDP协议,乱码的问题
1个回答
展开全部
【解决办法】:
服务器端:
BufferedReader in = new BufferedReader(new InputStreamReader(
process.getInputStream(),"utf-8"));
PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(process.getOutputStream(),"utf-8")),true);
out.println((of.getOfferFeeInfo()[i].getCumulantName());
客户端:
PrintWriter out =
new PrintWriter(new BufferedWriter(new OutputStreamWriter(client.getOutputStream(),"utf-8")),true);
out.println(imsi.trim());
out.flush();
BufferedReader in = new BufferedReader(new InputStreamReader(client
.getInputStream(),"utf-8"));
result = in.readLine();
服务器端:
BufferedReader in = new BufferedReader(new InputStreamReader(
process.getInputStream(),"utf-8"));
PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(process.getOutputStream(),"utf-8")),true);
out.println((of.getOfferFeeInfo()[i].getCumulantName());
客户端:
PrintWriter out =
new PrintWriter(new BufferedWriter(new OutputStreamWriter(client.getOutputStream(),"utf-8")),true);
out.println(imsi.trim());
out.flush();
BufferedReader in = new BufferedReader(new InputStreamReader(client
.getInputStream(),"utf-8"));
result = in.readLine();
迪凯特科技(北京)有限公司_
2025-01-03 广告
2025-01-03 广告
协议一般要包含:起始符、数据、校验码、结束符,5个部分的定义。 其中 起始符、结束符,不能与其他数据重码。 如只要传输字母与数字,可以看下ASCII码表,使用非数字和字母的符号做起始结束符即可,如{}; 数据长度码即表示此串数据包的数据长度...
点击进入详情页
本回答由迪凯特科技(北京)有限公司_提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询