我正在研究在Linux平台上开发一个小的(读取:基本的)Web服务器,我不知道从哪里开始.
我希望它能做的是:
我熟悉HTTP标头,是一位经验丰富的PHP和.Net Web开发人员,但我不知道从哪里开始这项任务.
你能用一些资源建议我弥合学习曲线吗?
mct*_*ylr 39
从上到下,您需要了解:
因此,您必须学习编写基本的Unix应用程序,用于TCP/IP网络编程的BSD套接字编程以及HTTP协议.
常用文本包括:
Unix应用程序开发:
TCP/IP(套接字)编程:
HTTP协议
Ked*_*are 18
对于SIMPLE/BASIC/ULTRA-LIGHT HTTP服务器,程序流应该类似(伪代码):
----Main thread----
Load settings
while true do
Wait for connection
Connection received, create a new thread and transfer this connection to this thread.
end
----Connection thread----
Analyze request
if dynamic content do
Dump the HTTP request and send it to the interpreter
Wait for response from the interpreter
Read response header from the interpreter
Stream response
else if static content do
Load requested file
Stream file content
end
(Optional) Cache the response if size < X
Send the response
Close the socket
Run Code Online (Sandbox Code Playgroud)
所以你应该学习线程,进程间通信(如果你想与解释器交互),Socket编程和HTTP协议.
所有细节都不能在这里解释
访问http://www.linuxhowtos.org/C_C++/socket.htm以使用C创建基本服务器.
另一个由IBM提供:http://www.ibm.com/developerworks/systems/library /es-nweb/index.html
归档时间: |
|
查看次数: |
20405 次 |
最近记录: |