资源简介
简易的web服务器实现, 有httpd 服务器通过管道实现动态流程. 解析协议发送响应. 并附带一个 简易的 client.c 的测试客户端
代码片段和文件信息
#include
#include
#include
#include
#include
#include
#include
#include
#include
//4.0 控制台打印错误信息 fmt必须是双引号括起来的宏
#define CERR(fmt ...) \
fprintf(stderr“[%s:%s:%d][error %d:%s]“ fmt “\r\n“\
__FILE__ __func__ __LINE__ errno strerror(errno)##__VA_ARGS__)
//4.1 控制台打印错误信息并退出 t同样fmt必须是 ““括起来的字符串常量
#define CERR_EXIT(fmt...) \
CERR(fmt##__VA_ARGS__)exit(EXIT_FAILURE)
//4.3 if 的 代码检测
#define IF_CHECK(code) \
if((code) < 0) \
CERR_EXIT(#code)
//待拼接的字符串
#define _STR_HTTP_1 “GET /index.html HTTP/1.0\r\nUser-Agent: Happy is good.\r\nHost: 127.0.0.1:“
#define _STR_HTTP_3 “\r\nConnection: close\r\n\r\n“
// 简单请求一下
int main(int argc char* argv[])
{
char buf[1024];
int sfd;
struct sockaddr_in saddr = { AF_INET };
int len port;
// argc 默认为1 第一个参数 就是 执行程序串
if((argc != 2) || (port=atoi(argv[1])) <= 0 )
CERR_EXIT(“Usage: %s [port]“ argv[0]);
// 开始了就这
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2016-03-14 20:41 重构\
文件 1650 2016-03-14 20:40 重构\client.c
文件 13006 2016-03-14 20:40 重构\client.out
文件 12536 2016-03-14 20:38 重构\httpd.c
文件 24048 2016-03-14 20:39 重构\httpd.out
文件 110 2016-03-14 18:27 重构\index.html
文件 121 2016-03-14 18:47 重构\Makefile
- 上一篇:ChartCtrl
- 下一篇:mfcdll调用方法
相关资源
- ComputerArchitectureAQuantitativeApproach5th.p
- Classificationoftime-seriesimagesusingdeepcnn.
- 微擎小程序榆落微时光1.0.23小程序前
- S7-1200仿真教程.pdf
- 6908d19c7e04dbde289b4dec5403d7fb.rar
- 泛函分析:理论和应用.pdf
- _源代码.rar
- sogoupinyin-2.2.0.0102-2.zip
- 模式分析的核方法中文版和英文版合
- zw_qq_41143492-10381309-学生考试系统.zip
- zw_feifan50-9720417-MissionPlanner1.3.32PlayUA
- zw_weixin_42810059-10567648-数学分析考研笔
- 刺客.rar
- zw_DXF转G代码.zip
- 彩票开发源码.zip
- 斯坦福-IntroductiontoRobotics.zip
- zw_gephi-0.8.2-beta.setup.zip
- zw_嵌入式网络那些事(完整中文版)
- zw_WINDOWSAPI程序设计参考大全.zip
- zw_ssm-crm-new.zip
- zw_SolidWorks2014中文版基础教程.zip
- zw_Altera官方元件封装库.zip
- zw_AutofacIOC.zip
- zw_ionicDemo.zip
- Location虚拟定位ios12.1破解版.zip
- 流体模拟插件NextLimitRealFlowC4D2.6.5.00
- 老虎淘宝客v6.0.15.zip
- iSkysoft Video Converter Ultimate 5.1简体中文
- 20180704全彩种彩票网站源码.rar
- 暗影2MAC12系统安装clover.zip
评论
共有 条评论