当我使用MS telnet时,我得到的每个字符都重复而没有CRLF,但使用OSX telnet时,我的输入直到我CRLF才发送到服务器。
所以我发现我可以先打开(MS)telnet并输入
set crlf
但是当我尝试打开连接时,客户端坐在那里并说它正在连接,但是失败了!
下面的这些命令有什么区别?如何使用 open 命令连接?
命令:
工作:
telnet localhost 8010 // but I get unwanted auto-send
不起作用:
telnet
set crlf
open localhost 8010
代码:
public class SingleThreadedBlockingServerBasic {
public static void main(String[] args) throws IOException {
ServerSocket serverSock = new ServerSocket(8010);
while (true) {
// Connect client and serverSock - Tell serverSock to accept client Socket
Socket client = serverSock.accept();
InputStream in = client.getInputStream();
OutputStream out = client.getOutputStream();
int data;
// Read the int-read into the 8k buffer at offset 0 from the inputstream. inputstream receives data off
// of the client Socket.
in.transferTo(out);
}
}
}