正在显示
1 个修改的文件
包含
97 行增加
和
0 行删除
src/server/spserver/README
0 → 100644
1 | + spserver README | ||
2 | + | ||
3 | +1.Introduction | ||
4 | + | ||
5 | +spserver is a TCP server framework library written in C++ based on libevent. | ||
6 | + | ||
7 | +spserver implements the Half-Sync/Half-Async and the Leader/Follower patterns. | ||
8 | + | ||
9 | +More detail about the Half-Sync/Half-Async and Leader/Follower patterns: | ||
10 | + | ||
11 | + http://www.cs.wustl.edu/~schmidt/PDF/HS-HA.pdf | ||
12 | + http://www.cs.wustl.edu/~schmidt/PDF/lf.pdf | ||
13 | + | ||
14 | +Code description: | ||
15 | + | ||
16 | + SP_Server class implements the Half-Sync/Half-Async pattern. | ||
17 | + | ||
18 | + SP_Server, SP_EventCallback, SP_Session, SP_Request(SP_MsgDecoder), SP_Response(SP_Message) | ||
19 | + The asynchronous layer, which receives the asynchronous requests | ||
20 | + | ||
21 | + SP_EventArg::mInputResultQueue, SP_EventArg::mOutputResultQueue | ||
22 | + The queueing layer, which buffers the requests | ||
23 | + | ||
24 | + SP_Executor, SP_ThreadPool, SP_Handler | ||
25 | + The synchronous layer, which contains several threads of control blocked | ||
26 | + on the queueing layer | ||
27 | + | ||
28 | + SP_LFServer class implements the Leader/Follower pattern. | ||
29 | + | ||
30 | +The spserver code was developed under Linux, but has also been tested under Solaris. | ||
31 | + | ||
32 | +You can get the code from the spserver home page: | ||
33 | + | ||
34 | + http://code.google.com/p/spserver/ | ||
35 | + | ||
36 | +2.Building | ||
37 | + | ||
38 | +Before building spserver, libevent must been installed. Test with libevent 1.1 and 1.2. | ||
39 | + | ||
40 | +You can donwload libevent from its home page: | ||
41 | + | ||
42 | + http://www.monkey.org/~provos/libevent/ | ||
43 | + | ||
44 | +Edit spserver/Makefile to specify the path of libevent: | ||
45 | + | ||
46 | + LIBEVENT_INCL = -I<path_to_libevent_include> | ||
47 | + LIBEVENT_LIB = -L<path_to_libevent_library> -levent | ||
48 | + | ||
49 | +To build libspserver.so, type | ||
50 | + | ||
51 | +$ cd spserver | ||
52 | +$ make | ||
53 | + | ||
54 | +This will build all the targets include examples. You can run the | ||
55 | +example programs: | ||
56 | + | ||
57 | +$ ./testsmtp | ||
58 | +[msg] This server is listening on port [1025]. | ||
59 | + | ||
60 | +Open another console, use telnet to test: | ||
61 | + | ||
62 | +$ telnet 127.0.0.1 1025 | ||
63 | + Trying 127.0.0.1... | ||
64 | + Connected to 127.0.0.1. | ||
65 | + Escape character is '^]'. | ||
66 | + | ||
67 | + 220 SMTP Server Ready | ||
68 | + helo abc | ||
69 | + 250 ok. | ||
70 | + mail from:<abc@abc.com> | ||
71 | + 250 sender ok. | ||
72 | + rcpt to:<foo@bar.com> | ||
73 | + 250 recipient ok. | ||
74 | + data | ||
75 | + 354 Start mail input; end with <CRLF>.<CRLF> | ||
76 | + From: abc@abc.com | ||
77 | + To: foo@bar.com | ||
78 | + Subject: test | ||
79 | + | ||
80 | + test | ||
81 | + . | ||
82 | + 250 Requested mail action okay, completed. | ||
83 | + quit | ||
84 | + 221 Closing connection. Good bye. | ||
85 | + Connection closed by foreign host. | ||
86 | + | ||
87 | +3.Credits | ||
88 | + | ||
89 | +Special thanks go to Andrew Danforth, who provides a good solution to | ||
90 | +use libevent in multithreaded environment. | ||
91 | + | ||
92 | +Any and all comments are appreciated. | ||
93 | + | ||
94 | +Enjoy! | ||
95 | + | ||
96 | + -- stephen liu <stephen.nil@gmail.com> | ||
97 | + |
请
注册
或
登录
后发表评论