public class TestServer1 {
/**
* @param args
*/
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
ServerSocket ss=new ServerSocket(5000);
Socket s=ss.accept();
InputStream is=s.getInputStream();
byte[] b=new byte[200];
int len;
len=is.read(b, 0,b.length);
while(-1!=len)
{
System.out.println(new String(b));
len=is.read(b, 0,b.length);
}
}
}
这是服务端
public class TestClent {
/**
* @param args
*/
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
Socket s=new Socket("127.0.0.1",5000);
OutputStream os=s.getOutputStream();
os.write("asdasd".getBytes());
os.write("asdasd".getBytes());
}
}
这是客户端
怎么报
asdasd |
|