Github仓库地址
仓库地址:https://github.com/antirez/smallchat
下载代码
git clone git@github.com:Tinywan/smallchat.git
编译
cd smallchat/
gcc -o smallchat smallchat.c
参数 -o 指定一个输出文件,这里为smallchat。smallchat.c为源文件
编译后会生成一个smallchat 二进制文件
smallchat$ ls
Makefile README.md smallchat smallchat.c
直接启动服务端二进制文件即可
./smallchat
聊天
端口
服务端默认端口是7771。当然你也可以修改重新编译成自己想要的端口
#define SERVER_PORT 7711
终端
终端1
telnet 127.0.0.1 7711
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
Welcome to Simple Chat! Use /nick <nick> to set your nick.
// 设置客户端昵称 /nick 你的昵称
/nick tinywan001
// 发送消息
This is just a programming example (tinywan001)
终端2
telnet 127.0.0.1 7711
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
Welcome to Simple Chat! Use /nick <nick> to set your nick.
// 设置客户端昵称 /nick 你的昵称
/nick tinywan002
// 发送消息
Since I wrote this little program (tinywan002)
服务端
./smallchat
Connected client fd=4
Connected client fd=5
tinywan002> Since I wrote this little program (tinywan002)
tinywan001> This is just a programming example (tinywan001)
tinywan001> 001
tinywan002> 002
tinywan002> 002002002
tinywan001> 001001001001
Disconnected client fd=5, nick=tinywan002
Disconnected client fd=4, nick=tinywan001
其它
telnet 命令
telnet是一种远程连接协议,用于通过网络连接到远程设备进行控制和操作。其中,ip是指连接的远程设备的ip地址。使用telnet ip命令,在命令行中输入telnet 后输入连接的ip地址和端口号,就可以远程连接到目标设备进行操作了。
具体命令格式如下:
telnet ip_address port
本站资源仅供学习交流使用请勿商业运营,严禁使用模板&源码从事违法,侵权等非法活动!如链接失效内容有误,请到评论反馈。
免费声明
- 本网站的文章内容可能来源于网络,仅供大家学习与参考,如有侵权,请联系站长QQ:304906607进行删除处理。
- 文章采用: 《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)。
- 本站资源大多存储在云盘,如发现链接失效,请联系我们我们会第一时间更新。
- 本站一切资源不代表本站立场,并不代表本站赞同其观点和对其真实性负责。
- 本站一律禁止以任何方式发布或转载任何违法的相关信息,访客发现请向站长举报
- 本站永久网址:https://www.aybk.cn
Spring Boot + Vue/前后端分离/人不分离/博客系统
« 上一篇
11-09
境外esim手机号码获取教程/境外手机号码注册教程
下一篇 »
11-09



发表评论
请先登录后才能发表评论