telnet
2015-05-31 09:25
344 查看
telnet has default open port 23, which will remote login. But it has much more functions and can almost
fullfill any network service.
it'll help you learn network protocols and debug new developed ones.
1. use telnet to access web
telnet baidu.com 80
and use http protocol to access :
GET / HTTP/1.1
Host: baidu,com
and then you will get response
2. use telnet can access any network service:
here we implement a simple echo server and use telnet to access it
bash-4.3> python echo_server.py
open another terminal and telnet it:
bash-4.3> telnet localhost 50000
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
hello
hello
Connection closed by foreign host.
final: to exit telnet session:
^] q
see man telnet
fullfill any network service.
it'll help you learn network protocols and debug new developed ones.
1. use telnet to access web
telnet baidu.com 80
and use http protocol to access :
GET / HTTP/1.1
Host: baidu,com
and then you will get response
2. use telnet can access any network service:
here we implement a simple echo server and use telnet to access it
#! /usr/bin/python from socket import * import sys host = '' port = 50000 bufsize = 1024 addr = (host, port) sock = socket(AF_INET, SOCK_STREAM) sock.bind(addr) sock.listen(5) try: while True: c_sock, addr = sock.accept() data = c_sock.recv(bufsize) if data: print "receive data %s" %data c_sock.send(data) else: break c_sock.close() sock.close() except KeyboardInterrupt: sock.close() sys.exit()open a terminal and start the echo server:
bash-4.3> python echo_server.py
open another terminal and telnet it:
bash-4.3> telnet localhost 50000
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
hello
hello
Connection closed by foreign host.
final: to exit telnet session:
^] q
see man telnet
相关文章推荐
- 百度地图API的学习
- 类的默认赋值函数
- TabHost.TabSpec中的标签实现图文左右排(默认上下排)
- 百度地图API的学习
- Unity3d在安卓平台下使用sqlite存储操作数据
- 在windows server 2008上面装chrome driver 出错: cannot find Chrome driver
- 培训感悟
- 软考小结
- TabSpec和TabHost实例
- 第二阶段 冲刺第四天
- 微服务实战(一):微服务架构的优势与不足
- c++基础学习(02PM)
- ProgressBar
- 在ORACLE存储过程中创建临时表
- TabSpec与TabHost
- ShapeShifter 连续多次复制的剪贴板
- 单例模式
- 【超实用软件分享】ShapeShifter 连续多次复制的剪贴板
- ViewPage+Fragment的使用例子
- 自学抓去淘女郎所有模特美女的图片 手稿