你这获取完数据就把socket关闭掉了,应该方才trycatch后面的finally里面类似这样的try{ //...}catch(Exception e){ //。。。}finally{ if(socket!=null){ socket.close(); }}