【问题标题】:how to close connection without full the byte array如何在不完整字节数组的情况下关闭连接
【发布时间】:2014-02-18 15:27:26
【问题描述】:

我多次尝试为某些设备创建 telnet 会话以发送命令。当我运行这个程序时,它使用 512 字节字符。如果我增加字节大小,即使会话关闭,程序也不会启动另一个会话,因为有一个 2048 字节的字符。我该如何解决这个问题?

byte[] buff = new byte[512];
int ret_read = 0;
do {
    ret_read = instr.read(buff);
    if(ret_read > 0) {
        //sending some commands        
    }
} while (ret_read >= 0);

【问题讨论】:

    标签: java connection bytearray telnet


    【解决方案1】:

    也许尝试使用:

    BufferedInputStream is = new BufferedInputStream(socket.getInputStream(), 512);
    

    【讨论】:

      猜你喜欢
      • 2019-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-04
      • 1970-01-01
      • 2011-04-15
      • 2011-05-20
      相关资源
      最近更新 更多