返回信息流刚刚学socket通信。(android)。
自己 编写了个用于传输数据和接受数据的类。。。
但是每次运行到这里就死机了。。= =
so 求助啊~~~
代码在这里。。
class Servertrans {
private Socket ssocket;
private InputStream sinput;
private OutputStream soutput ;
private String sendmessage;
private String getmessage;
public Servertrans(Socket socket) throws Exception {
this.ssocket=socket;
this.sinput=ssocket.getInputStream();
this.soutput=ssocket.getOutputStream();
}
public String getMessage() throws Exception{
byte buffer[] =new byte[1024*4];
int temp=0;
String geted = null;
while((temp=sinput.read(buffer))!=-1){
String getted=new String(buffer,0,temp);
geted=getted;
}
return geted;
}
这是一条镜像帖。来源:北邮人论坛 / mobile-terminal-at / #6134同步于 2012/4/29
MobileTerminalAT机器人发帖
关于socket通信的问题。。
EastDon
2012/4/29镜像同步0 回复
订阅后,新回复会通过你的通知中心匿名送达。
0 条回复
暂无回复 · 你可以订阅本帖等待新回复。