报错内容如下
01-13 15:47:41.352: WARN/System.err(1476): java.net.SocketException: Bad file number
01-13 15:47:41.352: WARN/System.err(1476):
     at org.apache.harmony.luni.platform.OSNetworkSystem.readSocketImpl(Native Method)
01-13 15:47:41.352: WARN/System.err(1476):
     at org.apache.harmony.luni.platform.OSNetworkSystem.read(OSNetworkSystem.java:358)
01-13 15:47:41.352: WARN/System.err(1476):
     at org.apache.harmony.luni.net.PlainSocketImpl.read(PlainSocketImpl.java:561)
01-13 15:47:41.352: WARN/System.err(1476):
     at org.apache.harmony.luni.net.SocketInputStream.read(SocketInputStream.java:88)
01-13 15:47:41.362: WARN/System.err(1476):
     at com.order.NetWorkService$TCPListenThread.run(NetWorkService.java:251)
01-13 15:47:41.362: ERROR/NetWorkService(1476):报错的代码如下:readBytes =  inputStream.read(pkt, 0, minReadSize);
不知道是什么原因造成的呢

解决方案 »

  1.   

    HttpPost提前释放了吧?后面再读就错了
      

  2.   

    socket连接的,不是用的http连接的
      

  3.   

    Bad file number 是指错误的文件描述符, 可能出现的原因是也许已经被修改或者释放了
      

  4.   

    public int readByte(byte[] pkt,InputStream inStream, int dataLength, int offset)
    {
    int readBytes = 0;
    try 
    {
    readBytes = inStream.read(pkt, offset, dataLength);

    catch (IOException e) 
    {

    if(!isLongConnect)
    stopListen();
    }
    return readBytes;
    }
      

  5.   

    try {
    readBytes =  inStream.read(pkt, 0, minReadSize);
    if(readBytes < minReadSize)
    {
    if(null != mDlgTable)
    {
    if(!mIsHurry)
    {
    mDlgTable.getDelay();
    mIsHurry = false;
    }
    }
    if(!isLongConnect)
    {
    stopListen();
    break;
    }
    }
    } catch (Exception e) {
    e.printStackTrace();
                                      {
      

  6.   

    socket连接的
    try {
    mHost = InetAddress.getByName(hostIP);
    Log.i("network", "148");
    mSocket.setReceiveBufferSize(10*1024);  
    mSocket.setTcpNoDelay(true); 
    mSocket.connect(new InetSocketAddress(hostIP, port));
    if(!isLongConnect)
    mSocket.setSoTimeout(30000);
    mOutputStream = mSocket.getOutputStream();
    mIsConnected = true;
    mHostIP = new String();
    mHostIP = hostIP;
    mPort = port;
    if (null == mTCPListenThread) {
    mTCPListenThread = new TCPListenThread();
    mTCPListenThread.start();

    return true;
    } catch (Exception e) {
    System.out.println("TCPListener start exception  error");
    Log.e(TAG, "connectWithServer(String hostIP, int port) error");
    // e.printStackTrace();
    if(null != mDlgTable)
    {
    mDlgTable.sendDelay();
    }
    return false;