啥都不说先上代码(纯c有点难,写的稳定性太差)
#include <cstring>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#include <cstdlib>
#include <thread>
#include <iostream>
#include <vector>
#include <fstream>
#include <sstream>
class Request {
std::string _data;
public:
Request(std::string data) {
this->_data = data;
}
static std::string requestUrl(const std::string &url) {
int flag[2];
int ii = 0;
for (int i = 0; i < url.size(); i++) {
if (url[i] == ' ') {
flag[ii] = i;
ii++;
if (ii == 2) {
break;
}
}
}
return url.substr(flag[0] + 1, flag[1] - flag[0]);
}
};
class WebServer {
private:
char *_buf;
int _bufSize;
int _maxConnNum;
int _serverPort;
int _listenFD;
const std::string _baseDir = "www";
sockaddr_in _serverAddr;
public
c++ 实现一个简单的静态网页(文件)加载程序
最新推荐文章于 2024-04-16 18:15:04 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)