提交 94233773 编写于 作者: X xuchi

简单认识http请求

上级 b62314ae
......@@ -3,7 +3,8 @@
// 在不同操作系统下面选择最佳网络通信模型
#if _WIN32 // windows系统下面会定义此宏
#include "TcpIocpServer.hpp" // using iocp, only windows.
//#include "TcpIocpServer.hpp" // using iocp, only windows.
#include "TcpSelectServer.hpp" // 方便讲解
#elif __linux__ // 在linux系统下面会定义此宏
#include "TcpEpollServer.hpp" // using epoll, only linux.
#else
......@@ -15,7 +16,8 @@ namespace doyou {
namespace io {
#if _WIN32
typedef TcpIocpServer TcpServerMgr;
//typedef TcpIocpServer TcpServerMgr;
typedef TcpSelectServer TcpServerMgr;
#elif __linux__
typedef TcpEpollServer TcpServerMgr;
#else
......
......@@ -78,5 +78,25 @@ IP直接存入黑名单中,所以,服务端获取客户端IP地址很有意
24.在一个进程中,主线程已经退出,子线程还没有退出,子线程会被破退出,同时可能出现系统错误。
25.IOCP网络模型是采用异步方式实现的。
26.当前服务器程序存在问题:客户端在发送一个随机字符串数据请求时,程序可能会崩溃。
服务器程序的健壮性有待提高。要处理这种异常情况。
27.http请求解析(简单认知:域名,IP地址,http服务器之间的关系):
示例:
// http请求行
GET /login.php HTTP/1.1\r\n
// http请求头
Host: 127.0.0.1:4567\r\nConnection: keep-alive\r\nCache-Control: max-age=0\r\nsec-ch-ua: \"Chromium\";v=\"112\", \"Microsoft Edge\";v=\"112\", \"Not:A-Brand\";v=\"99\"\r\nsec-ch-ua-mobile: ?0\r\nsec-ch-ua-p...
// http请求体为空
当在浏览器通过域名或ip+port方式可以访问http服务器,可以向指定http服务器发送一条网络消息,
示例如上。
http协议不一定是基于TCP的,只需要一个保证数据传输的协议即可。当前很多http的连接
都是通过tcp的连接方式,先通过tcp连接到服务器,再建立http协议数据的传输。所以,
通过域名或者URL也能访问到tcp的服务端,tcp服务器并不是一个web服务器,但是只要http
提供了正常的ip+port就能访问到。并且,tcp服务器收到了正确的数据。
Info [2023-4-14 22:51:14]Log::setLogPath success,<ServerLog.txt,w>
Error [2023-4-14 22:51:14]Config::getStr not find <strIP>
Info [2023-4-14 22:51:14]Config::getStr strIP=any
Error [2023-4-14 22:51:14]Config::getStr not find <nPort>
Info [2023-4-14 22:51:14]Config::getInt nPort=4567
Error [2023-4-14 22:51:14]Config::getStr not find <nThread>
Info [2023-4-14 22:51:14]Config::getInt nThread=1
Error [2023-4-14 22:51:14]Config::getStr not find <nSendBuffSize>
Info [2023-4-14 22:51:14]Config::getInt nSendBuffSize=10240
Error [2023-4-14 22:51:14]Config::getStr not find <nRecvBuffSize>
Info [2023-4-14 22:51:14]Config::getInt nRecvBuffSize=8192
Error [2023-4-14 22:51:14]Config::getStr not find <nMaxClient>
Info [2023-4-14 22:51:14]Config::getInt nMaxClient=65535
Info [2023-4-14 22:51:14]-ipv4
Info [2023-4-14 22:51:14]create socket<448> success...
Info [2023-4-14 22:51:14]bind port<4567> success...
Info [2023-4-14 22:51:14]listen port<448> success...
Info [2023-4-14 22:51:15]thread<1>,time<1.004794>,socket<448>,Accept<0>,Join<0>,recv<0>,msg<0>
Info [2023-4-14 22:51:16]thread<1>,time<1.007067>,socket<448>,Accept<0>,Join<0>,recv<0>,msg<0>
Info [2023-4-14 22:51:17]thread<1>,time<1.008760>,socket<448>,Accept<0>,Join<0>,recv<0>,msg<0>
Info [2023-4-14 22:51:18]thread<1>,time<1.008488>,socket<448>,Accept<0>,Join<0>,recv<0>,msg<0>
Info [2023-4-14 22:51:19]thread<1>,time<1.008667>,socket<448>,Accept<0>,Join<0>,recv<0>,msg<0>
Info [2023-4-14 22:51:20]thread<1>,time<1.003613>,socket<448>,Accept<0>,Join<0>,recv<0>,msg<0>
Info [2023-4-14 22:51:21]Accept_Ipv4 : 127.0.0.1
Info [2023-4-14 23:10:40]Accept_Ipv4 : 127.0.0.1
Info [2023-4-14 23:10:40]thread<1>,time<15.195773>,socket<448>,Accept<2>,Join<2>,recv<0>,msg<0>
Info [2023-4-14 23:10:40]checkHeart dead:s=496,time=1159802
Info [2023-4-14 23:10:40]~Client[sId=1 id=1 socket=496]
Info [2023-4-14 23:10:41]Client::Destory[sId=1 id=1 socket=496]
Info [2023-4-14 23:10:41]checkHeart dead:s=500,time=1159802
Info [2023-4-14 23:10:41]Accept_Ipv4 : 127.0.0.1
Info [2023-4-14 23:10:41]~Client[sId=1 id=2 socket=500]
Info [2023-4-14 23:10:41]Client::Destory[sId=1 id=2 socket=500]
Info [2023-4-14 23:10:41]thread<1>,time<1.005550>,socket<448>,Accept<1>,Join<0>,recv<0>,msg<0>
Info [2023-4-14 23:10:43]thread<1>,time<1.006655>,socket<448>,Accept<1>,Join<0>,recv<0>,msg<0>
Info [2023-4-14 23:10:44]thread<1>,time<1.006405>,socket<448>,Accept<1>,Join<0>,recv<0>,msg<0>
Info [2023-4-14 23:10:45]thread<1>,time<1.008284>,socket<448>,Accept<1>,Join<0>,recv<0>,msg<0>
Info [2023-4-14 23:10:46]thread<1>,time<1.009576>,socket<448>,Accept<1>,Join<0>,recv<0>,msg<0>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册