[code="java"]
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.Socket;
import java.net.UnknownHostException;
public class SocketSend
{
public static void main(String[] args)
{
String ip = "192.168.8.180";
int port = 8080;
try
{
Socket socket = new Socket(ip, port);
OutputStream os = socket.getOutputStream();
InputStream is = socket.getInputStream();
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(os));
String line = "aaa";
bw.write(line);
bw.flush();
System.out.println("发送:"+line);
BufferedReader br = new BufferedReader(new InputStreamReader(is));
StringBuffer sb = new StringBuffer();
if ((line = br.readLine()) != null)
{
sb.append(line);
}
System.out.println("返回:"+sb.toString());
br.close();
bw.close();
socket.close();
} catch (UnknownHostException e)
{
e.printStackTrace();
} catch (IOException e)
{
e.printStackTrace();
}
}
}
[/code]
正常情况下 服务器会分三次返回 111 222 333
但是我的程序只能接受到111,怎么才能接收到 222 和 333呢 ?