当前位置: 代码迷 >> J2SE >> JAVA 数据流,该怎么解决
  详细解决方案

JAVA 数据流,该怎么解决

热度:176   发布时间:2016-04-24 13:07:50.0
JAVA 数据流,急
public static DataInputStream in;
public static DataOutputStream out;
private void createIO() {
try {
in = new DataInputStream(s.getInputStream());
out = new DataOutputStream(s.getOutputStream());
} catch (Exception ex) {
ex.printStackTrace();
}
}
private void 方法1() {
try {
s = new Socket("192.168.119.2", 7501);

} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (s != null) {
createIO();
try {

out.write(headSignIn);
out.write(byte[]);
  out.flush();
num = in.read(bt);
  ....
}---成功

private void 方法2() {
try {
out.write(headSignIn);
out.write(byte[]);  
  out.flush();
num = in.read(bt);
  ....
}---失败 提示java.net.SocketException: Software caused connection abort: socket write error


我先调用方法1成功连接,后台收到包,也可收到后台返回包。然后调用方法2,后台没反应,应该是程序数据没发送成功。
请大家帮忙看看。




------解决方案--------------------
是不是socket已经关闭了?
------解决方案--------------------
connection abort!!!连接中断
  相关解决方案