public class Server {
public static void main(String[] args){
try{
ServerSocket ss = new ServerSocket(7777);
Socket so = ss.accept();
ObjectInputStream dis = new
ObjectInputStream(so.getInputStream());
ObjectOutputStream dos = new
ObjectOutputStream(so.getOutputStream());
while(true){
int s = Integer.parseInt(dis.readUTF());
System.out.println(s);
dos.writeUTF("ok");
System.out.println(dis.readObject());
if (s == 10){
dos.writeUTF("ok2");
break;
}else{
dos.writeUTF("resend");
}
}
so.close(); dos.close(); dis.close();
}catch(Exception e){
e.printStackTrace();
}
}
}
public class Client {
public static void main(String[] args){
try{
Socket so = new Socket("127.0.0.1",7777);
ObjectOutputStream dos = new
ObjectOutputStream(so.getOutputStream());
ObjectInputStream dis = new
ObjectInputStream(so.getInputStream());
int num = 10;
while(true){
dos.writeUTF(num+"");
System.out.println(dis.readUTF());
dos.writeUTF(new String("aaa"));
String str = dis.readUTF();
if (!"resend".equals(str)) break;
}
so.close(); dos.close(); dis.close();
}catch(Exception e){
e.printStackTrace();
}
}
}
问题是 为什么在客户端 和 服务器端 都得不到输出呢?
解决方案 »
- Servlet 问题 请高手 解决 谢谢!!
- org.apache.jasper.JasperException: Unable to load class for JSP是什么原因请帮帮忙!
- spring中关于事务代理的疑问
- [200分???关于jpetstore的aop配置]老是提示:not eligible for auto-proxying
- jquery ajax 不执行success回调函数
- OutOfMemorryError错误,请高手赐教!!!
- 怎样培训新人JSPStruts相关技术?请junnef(光明圣堂武士)、
- 高分求助(100),那儿有WebSphere最新版的下载?
- org.jboss.jmx.adaptor.rmi.RMIAdaptor
- 这个程序技术上是否可行
- JSP远程访问EJB
- ssh+proxool的web.xml配置问题
否则,数据回暂时保留在缓冲区,直到缓冲区满或被close之前。