Android 中,使用到socket套接字进行客户端的读写操作,需要新创建一个线程完成:
new Thread(){
public void run(){
try {
Socket client = new Socket("10.10.10.123 ",8000);
BufferedReader buf = new BufferedReader(new InputStreamReader(client.getInputStream()));
PrintWriter out = new PrintWriter(client.getOutputStream());
out.println("wendu");
out.flush();
InputStream ips = client.getInputStream();//定义输入流,来自于socket的输入流
byte[] bytes2 = new byte[20];