介绍

Linux 下流行的 telnet 实现有两个:

  1. GNU inetutils: http://ftp.gnu.org/gnu/inetutils/

  2. 哈佛netkit-telnet

编译

编译环境

Ubuntu 20.04.4 LTS

编译telnet-0.17

下载并解压安装包netkit-telnet_0.17.orig.tar.gz

编译源码

netkit-telnet-0.17# ./configure
netkit-telnet-0.17# make

遇到的问题

官方的代码编译还是会遇到一些代码本身的问题,需要做些修改。

undefined reference

commands.cc:(.text+0x25c4): undefined reference to `operator new(unsigned long)'
/usr/bin/ld: commands.cc:(.text+0x2651): undefined reference to `operator new(unsigned long)'
/usr/bin/ld: commands.cc:(.text+0x26e1): undefined reference to `operator new(unsigned long)' collect2: error: ld returned 1 exit status

原因:

申明了函数却没实现,一般是链接阶段出现

netkit-telnet-0.17# ./configure
Looking for a C++ compiler... gcc <<< 发现编译c++文件应该编译器要选g++

解决:修改configure文件中c++文件的编译器

# git diff
diff --git a/configure b/configure
index 429167a..e8780e7 100755
--- a/configure
+++ b/configure
@@ -122,7 +122,7 @@ EOF if [ x"$CXX" = x ]; then
echo -n 'Looking for a C++ compiler... '
- for TRY in egcs gcc g++ CC c++ cc; do
+ for TRY in egcs g++ CC c++ cc; do <<<修改

exit函数不存在

main.cc:92:2: error: 'exit' was not declared in this scope; did you mean 'Exit'?
92 | exit(1);
| ^~~~
| Exit
make[1]: *** [../MRULES:7: main.o] Error 1
make[1]: Leaving directory 'netkit-telnet-0.17/telnet'
make: *** [Makefile:8: telnet.build] Error 2

解决:

添加头文件

#include <cstdlib>

error: 'memcpy' was not declared

terminal.cc:696:5: error: 'memcpy' was not declared in this scope
696 | memcpy(new_tc.c_cc, old_tc.c_cc, sizeof(old_tc.c_cc));

解决:

c++ - ‘memcpy’ was not declared in this scope - Stack Overflow

运行

编译完成后生成可执行文件

//客户端
netkit-telnet-0.17/telnet/telnet
//服务端
netkit-telnet-0.17/telnetd/telnetd

运行client端

netkit-telnet-0.17/telnet# ./telnet
telnet> ?
Commands may be abbreviated. Commands are: close close current connection
logout forcibly logout remote user and close the connection
display display operating parameters
mode try to enter line or character mode ('mode ?' for more)
open connect to a site
quit exit telnet
send transmit special characters ('send ?' for more)
set set operating parameters ('set ?' for more)
unset unset operating parameters ('unset ?' for more)
status print status information
toggle toggle operating parameters ('toggle ?' for more)
slc set treatment of special characters z suspend telnet
environ change environment variables ('environ ?' for more)

运行server端

netkit-telnet-0.17/telnetd# ./telnetd -n
Usage: telnetd [-debug] [-D (options|report|exercise|netdata|ptydata)]
[-h] [-L login_program] [-n] [port]

最新文章

  1. ip地址转换
  2. struts学习
  3. Android中实现圆角矩形及半透明效果。
  4. App界面交互设计规范(转)
  5. css3背景颜色渐变
  6. Thread的第四天学习
  7. jqery筛选
  8. sublime模式下开启vim并修改esc
  9. maven 打包 时出现非法字符: /65279错误
  10. Javassist进行方法插桩
  11. LOJ2083 [NOI2016] 优秀的拆分 【哈希】【调和级数】
  12. Java中谈尾递归--尾递归和垃圾回收的比较
  13. [转载]linux下网卡漂移导致网络不可用
  14. 接口测试工具Jmeter
  15. pkusc2018数学题
  16. 【CF886E】Maximum Element DP
  17. HTML5-form表单
  18. spring mvc自定义数据转换
  19. Pthreads 环境配置,VisualStudio
  20. day4 正则表达式(regular)

热门文章

  1. 基于tauri打造的HTTP API客户端工具-CyberAPI
  2. Linux Block模块之IO合并代码解析
  3. JDBC数据库编程(java实训报告)
  4. Unity破窗游戏制作(简易版)
  5. 齐博X1-栏目的调用5
  6. 13-ORM-更新&amp;删除
  7. java中的垃圾回收算法与垃圾回收器
  8. linux重置密码
  9. C. 连锁商店(状压dp)
  10. Codeforces Round #817 (Div. 4)