当前位置: 技术问答>java相关
java 与c++用socket通讯的问题??字符串不能接收到??急啊!
来源: 互联网 发布时间:2015-08-02
本文导语: 与c++socket通讯,java为client ,发送能发送过去可是无法接受到返回来的字符串?? Socket gb_socket=new Socket("168.1.1.200",19999); input= new BufferedReader(new InputStreamReader(gb_socket.getInputStream())); out= new PrintWriter(new BufferedW...
与c++socket通讯,java为client ,发送能发送过去可是无法接受到返回来的字符串??
Socket gb_socket=new Socket("168.1.1.200",19999);
input= new BufferedReader(new InputStreamReader(gb_socket.getInputStream()));
out= new PrintWriter(new BufferedWriter(new OutputStreamWriter(gb_socket.getOutputStream())), true /* autoFlush */);
String info="7000888888";
String mm=info.trim();
out.println(mm);
//对接受的字符进行处理.....
String accstring;
accstring=input.readLine();
int m=accstring.length();//无反映!
System.out.println(accstring);
Socket gb_socket=new Socket("168.1.1.200",19999);
input= new BufferedReader(new InputStreamReader(gb_socket.getInputStream()));
out= new PrintWriter(new BufferedWriter(new OutputStreamWriter(gb_socket.getOutputStream())), true /* autoFlush */);
String info="7000888888";
String mm=info.trim();
out.println(mm);
//对接受的字符进行处理.....
String accstring;
accstring=input.readLine();
int m=accstring.length();//无反映!
System.out.println(accstring);
|
可能错误就出在用readLine();看看有没有其他办法
|
毕竟客户端和服务器端一般情况下对行结尾的处理是不一样的,所以错误可能出在那儿,用其他办法试试。。