免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: iunknown
打印 上一主题 下一主题

SPServer: 一个基于线程池(包括HAHS和LF)的开源服务器框架 [复制链接]

论坛徽章:
0
21 [报告]
发表于 2007-08-22 22:33 |只看该作者

增加了一个通用的 ssl proxy 实现

在实现了 ssl 的支持之后,使用 spserver 来实现一个 ssl proxy ,就很简单了。
为 spserver 增加了一个名为 sptunnel 的可执行程序,这是一个通用的 TCP ssl proxy 程序。
通用的意思就是可以作为任何给予 TCP 协议服务器做 ssl proxy,比如 http、smtp、pop3 这类。
在最新的 0.8 release 中,重构了一下目录,分开了 spserver 最基本的功能和各个插件。

最新代码下载:http://spserver.googlecode.com/files/spserver-0.8.src.tar.gz

sptunnel 的用法如下所示,默认侦听在 8080 端口,并转发到 google.com 。
运行之后,可以使用 IE 或者 firefox 来访问:https://<ip.of.sptunnel>:8080/


  1. bash-2.05a$ ./sptunnel -v
  2. Usage: ./sptunnel [-p <port>] [-t <threads>] [-r <backend>]

  3. bash-2.05a$ ./sptunnel -r 66.249.89.99:80
  4. sptunnel[7437]: Backend server - 66.249.89.99:80
  5. sptunnel[7437]: Listen on port [8080]
复制代码

[ 本帖最后由 iunknown 于 2007-8-22 22:37 编辑 ]

论坛徽章:
0
22 [报告]
发表于 2007-10-24 09:36 |只看该作者
请问楼主,假如client主动关闭连接,spserver如何得知

还有为什么close(fd)关不掉socket

论坛徽章:
0
23 [报告]
发表于 2007-10-28 19:39 |只看该作者
请问楼主,是不是因为没有event_del(fd),close(fd)才不会激发FIN????

论坛徽章:
0
24 [报告]
发表于 2007-11-16 17:58 |只看该作者

回复 #1 iunknown 的帖子

牛人,问个低级问题

编译出错,错误如下

event_msgqueue.c:125: error: previous definition of 'circqueue_pop_head' was here
event_msgqueue.c:138: error: redefinition of 'msgqueue_pop'
event_msgqueue.c:138: error: previous definition of 'msgqueue_pop' was here
event_msgqueue.c:138: error: redefinition of 'msgqueue_pop'
event_msgqueue.c:138: error: previous definition of 'msgqueue_pop' was here
event_msgqueue.c:161: warning: "struct event_base" declared inside parameter list
event_msgqueue.c:161: error: redefinition of 'msgqueue_new'
event_msgqueue.c:161: error: previous definition of 'msgqueue_new' was here
event_msgqueue.c:161: error: redefinition of 'msgqueue_new'
event_msgqueue.c:161: error: previous definition of 'msgqueue_new' was here
event_msgqueue.c: In function `msgqueue_new':
event_msgqueue.c:187: error: `EV_READ' undeclared (first use in this function)
event_msgqueue.c:187: error: `EV_PERSIST' undeclared (first use in this function)
event_msgqueue.c: At top level:
event_msgqueue.c:197: error: redefinition of 'msgqueue_destroy'
event_msgqueue.c:197: error: previous definition of 'msgqueue_destroy' was here
event_msgqueue.c:197: error: redefinition of 'msgqueue_destroy'
event_msgqueue.c:197: error: previous definition of 'msgqueue_destroy' was here
event_msgqueue.c:209: error: redefinition of 'msgqueue_push'
event_msgqueue.c:209: error: previous definition of 'msgqueue_push' was here
event_msgqueue.c:209: error: redefinition of 'msgqueue_push'
event_msgqueue.c:209: error: previous definition of 'msgqueue_push' was here
event_msgqueue.c:223: error: redefinition of 'msgqueue_length'
event_msgqueue.c:223: error: previous definition of 'msgqueue_length' was here
event_msgqueue.c:223: error: redefinition of 'msgqueue_length'
event_msgqueue.c:223: error: previous definition of 'msgqueue_length' was here
make: *** [event_msgqueue.o] 错误 1


这种错误应该是头文件包含上出错了吧,应该是头文件被包含多次吧?
我这用的是RedHat fc6
或者是否.c文件 gcc编译的问题呢?请指教一下!多谢!!

论坛徽章:
0
25 [报告]
发表于 2007-11-17 21:23 |只看该作者
原帖由 zsniper 于 2007-10-24 09:36 发表
请问楼主,假如client主动关闭连接,spserver如何得知

还有为什么close(fd)关不掉socket



抱歉,很久没有来 CU 看看。

如果 client 主动关闭连接,那么先调用 SP_Handler::error ,然后调用 SP_Handler::close 。
spserver 认为 client 主动关闭连接是一种错误。通常设计良好的协议都会有一个 client 和 server 的协商关闭的指令。
在 spserver 中,通过 SP_Handler::handle 返回 -1 来指示 server 主动关闭连接。

close(fd) 关不掉 socket ?能说明一下上下文吧?是指在 spserver 中吗?

[ 本帖最后由 iunknown 于 2007-11-17 21:24 编辑 ]

论坛徽章:
0
26 [报告]
发表于 2007-11-17 21:29 |只看该作者
原帖由 fengdays 于 2007-11-16 17:58 发表

编译出错,错误如下

event_msgqueue.c:125: error: previous definition of 'circqueue_pop_head' was here
event_msgqueue.c:138: error: redefinition of 'msgqueue_pop'
event_ms ...


刚刚找了一台 RedHat FC 试了一下,没有问题,可以编译。请提供一下 gcc 的版本。

-bash-3.1$ gcc --version
gcc (GCC) 4.1.2 20070626 (Red Hat 4.1.2-13)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

-bash-3.1$ cat /etc/redhat-release
Fedora Core release 6 (Zod)

-bash-3.1$ uname -a
Linux xxxxx 2.6.22.7-57.fc6 #1 SMP Fri Sep 21 19:45:12 EDT 2007 x86_64 x86_64 x86_64 GNU/Linux

[ 本帖最后由 iunknown 于 2007-11-17 21:53 编辑 ]

论坛徽章:
0
27 [报告]
发表于 2007-11-19 09:20 |只看该作者

gcc 版本

gcc --version
gcc (GCC) 3.4.6 20060404 (Red Hat 3.4.6-
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

论坛徽章:
0
28 [报告]
发表于 2007-11-19 09:32 |只看该作者

gcc+linux版本

gcc --version
gcc (GCC) 3.4.6 20060404 (Red Hat 3.4.6-8 )
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


uname -a
Linux Car-2 2.6.9-55.0.2.ELsmp #1 SMP Tue Jun 26 14:30:58 EDT 2007 i686 i686 i386 GNU/Linux

cat /etc/redhat-release
CentOS release 4.5 (Final)


晕啊,是CentOS啊, 唉! 原来不是FC!  服务器是维护部门安装的,我要求他们安装FC的啊,真晕!

这样的话是不是要更新一下gcc编译器版本啦?

论坛徽章:
0
29 [报告]
发表于 2007-12-18 09:32 |只看该作者
请问LZ,你的SP框架的服务器,是那种客户机请求,服务器相应的模式,那假如服务器主动广播,该如何使用你的这个框架呢~?

是不是再本地建立一个连接,好像GM一样 , 向在线的所有人广播?


还是直接创建一个广播task,压入input_queue中?

[ 本帖最后由 zsniper 于 2007-12-18 09:50 编辑 ]

论坛徽章:
0
30 [报告]
发表于 2007-12-18 09:42 |只看该作者
原帖由 iunknown 于 2007-11-17 21:23 发表



抱歉,很久没有来 CU 看看。

如果 client 主动关闭连接,那么先调用 SP_Handler::error ,然后调用 SP_Handler::close 。
spserver 认为 client 主动关闭连接是一种错误。通常设计良好的协议都会有一 ...



谢谢lz,是我犯了个低级错误,在testecho中定义了一个close()函数,结果程序在close(socket)的时候,调用的是我自己定义的这个close()

呵呵。。。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP