我有一个在服务器端使用套接字的客户端-服务器程序,读写是以这种方式发生的
soc = serversocket.accept();
System.out.println("Accepted");
in = new ObjectInputStream(soc.getInputStream());
out = new ObjectOutputStream(soc.getOutputStream());
if(in.readUTF() == null ? " " != null : !in.readUTF().equals(" "))
{
diskinfo.setPath(in.readUTF());
}
Item[] pac = diskinfo.get();
out.writeObject(pac);
同样在 cilent(android) 方面...
Log.v("read", "item");
soc = new Socket(InetAddress.getByName("10.0.2.2"), 3838);
output = new ObjectOutputStream(soc.getOutputStream());
input = new ObjectInputStream(soc.getInputStream());
try
{
output.writeUTF(path);
packets = (Item[]) input.readObject();
}
catch (ClassNotFoundException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
问题是,建立连接后程序卡住了,不报错也不例外;停下来