免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1809 | 回复: 2
打印 上一主题 下一主题

要用PERL写一个简单的proxy server [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-09-22 11:55 |只看该作者 |倒序浏览
现在要测试一个通过某种文本协议和SERVER交流的CLIENT软件, 作为其中一项的测试, 我的构想是在CLIENT和SERVER之间弄个proxy server.  这个proxy server可以让CLIENT和SERVER交流, 也可以模拟一些从SERVER传到CLIENT的一些乱七八糟的信息, 看看CLIENT是不是都能处理好.  有时候很难让SERVER发出这些乱七八糟的信息, 同过proxy server倒容易点.  
大家见过类似的代码吗?  我尽量想少写点代码, 一是时间, 二是对THREADING不熟悉, 三是希望少点DEBUG自己的测试工具.  哪位知道有这方面代码的, 帮忙提提醒吧, 先谢了.  OS是SOLARIS.

论坛徽章:
1
2015年辞旧岁徽章
日期:2015-03-03 16:54:15
2 [报告]
发表于 2006-09-22 13:17 |只看该作者
原帖由 learnscript 于 2006-9-22 11:55 发表
现在要测试一个通过某种文本协议和SERVER交流的CLIENT软件, 作为其中一项的测试, 我的构想是在CLIENT和SERVER之间弄个proxy server.  这个proxy server可以让CLIENT和SERVER交流, 也可以模拟一些从SERVER传到CLIE ...

用 POE 试试?
http://poe.perl.org/?POE_Cookbook
http://poe.perl.org/?POE_Cookbook/TCP_Forwarding
http://poe.perl.org/?POE_Cookbook/TCP_Port_Redirection

论坛徽章:
0
3 [报告]
发表于 2006-09-23 10:35 |只看该作者
Sorry, can not type chinese here.
POE seems to be the way to go.
The code samples from http://poe.perl.org/?POE_Cookbook/TCP_Port_Redirection seems to be what I have been looking for.
However, I am having problem with the forwarder_server_input function. The server can receive request from the client, but the client cannot receive the response from the server. The TCP_Port_Redirection script(my proxy) does receive and attempt to pass the response message to the client. Any suggestion?

# The forwarder has received data from its server side. Pass that
# through to the client.

sub forwarder_server_input {
my ( $heap, $input ) = @_[ HEAP, ARG0 ];
print "Received the following data from the server and attempt to send them to the client\n";
print "==\n$input\n=="; #this is the response from the server, but the client somehow can't receive it.
exists( $heap->{wheel_client} ) and $heap->{wheel_client}->put($in +put);
#maybe the wheel_client object is gone? If so, how do I keep it alive?
}
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP