我用手机发送消息给电脑,电脑上收到的却是空的消息,为什么发送不了“abc”呢? private View.OnClickListener BnSendListen=new View.OnClickListener() { @Override
public void onClick(View v) {
EtSend = (EditText) findViewById(R.id.MsgText);
// TODO Auto-generated method stub
Socket s=null;
DataOutputStream dout=null;
DataInputStream din =null; try
{
s =new Socket("192.168.8.229",191);
dout =new DataOutputStream(s.getOutputStream());
din =new DataInputStream (s.getInputStream());
s.setKeepAlive(true);
Thread.sleep(50, 0);
dout.writeBytes("abc");
dout.flush();
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
try{
if(dout != null){
dout.close();
}
if(din != null){
din.close();
}
if(s != null){
s.close();
}
}
catch(Exception e){
e.printStackTrace();
}
}
}
};
}
public void onClick(View v) {
EtSend = (EditText) findViewById(R.id.MsgText);
// TODO Auto-generated method stub
Socket s=null;
DataOutputStream dout=null;
DataInputStream din =null; try
{
s =new Socket("192.168.8.229",191);
dout =new DataOutputStream(s.getOutputStream());
din =new DataInputStream (s.getInputStream());
s.setKeepAlive(true);
Thread.sleep(50, 0);
dout.writeBytes("abc");
dout.flush();
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
try{
if(dout != null){
dout.close();
}
if(din != null){
din.close();
}
if(s != null){
s.close();
}
}
catch(Exception e){
e.printStackTrace();
}
}
}
};
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货