• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >python > python实现超简单端口转发的方法

python实现超简单端口转发的方法

作者: 字体:[增加 减小] 来源:互联网

通过本文主要向大家介绍了python实现端口扫描,python实现端口镜像,用python实现端口扫描,python 端口扫描,python 监听端口等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

本文实例讲述了python实现超简单端口转发的方法。分享给大家供大家参考。具体如下:

代码非常简单,实现了简单的端口数据转发功能,用于真实环境还需要再修改一下。
import socket
host = '127.0.0.1'          #Local Server IP
host2 = '127.0.0.1'   #Real Server IP
port = 6001 #Local Server Port
port2 = 7001 #Real Server Port
def ProcData(data):
    return data
    #add more code....
print "Map Server start from " + host + ":" + str(port) +" to " + host2 + ":" + str(port2) +"\r\n"
server = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
server.bind(('127.0.0.1',port))
print "127.0.0.1 Server start at "+ str(port) +"\r\n"
client = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
client.connect((host2,port2))
print host +" Client connect to " + host2 + ":"+str(port2)+"\n"
server.listen(5)
ss, addr = server.accept()
print 'got connected from',addr
while 1:
    msg = ss.recv(20480)
    print "Get:"+repr(msg)+"\r\n"
    client.send(msg)
    #print "Client send data %s to "%repr(msg)
    buf=client.recv(20480)
    #print "Client recv data %s from "%repr(buf)
    ss.send(buf)
    print "Send:"+repr(buf)+"\r\n"</div>

希望本文所述对大家的Python程序设计有所帮助。

</div>

您可能想查找下面的文章:

  • Python端口扫描简单程序
  • Python实现网络端口转发和重定向的方法
  • Python实现网络端口转发和重定向的方法
  • python检测远程端口是否打开的方法
  • python循环监控远程端口的方法
  • python实现端口转发器的方法
  • python实现超简单端口转发的方法
  • python检测远程端口是否打开的方法
  • python循环监控远程端口的方法
  • python实现端口转发器的方法

相关文章

  • python基础教程之常用运算符
  • Python命令启动Web服务器实例详解
  • python条件变量之生产者与消费者操作实例分析
  • Python彩色化Linux的命令行终端界面的代码实例分享
  • Python装饰器decorator用法实例
  • Python struct.unpack
  • python关闭windows进程的方法
  • python web框架学习笔记
  • pyqt和pyside开发图形化界面
  • Python中使用select模块实现非阻塞的IO

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • python提取页面内url列表的方法
    • 用Python输出一个杨辉三角的例子
    • Python图像灰度变换及图像数组操作
    • python返回昨天日期的方法
    • 解析Python中的变量、引用、拷贝和作用域的问题
    • 探索Python3.4中新引入的asyncio模块
    • python利用elaphe制作二维条形码实现代码
    • Python导入txt数据到mysql的方法
    • Python捕捉和模拟鼠标事件的方法
    • windows及linux环境下永久修改pip镜像源的方法

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有