1、前言
简单理解http协议,其实就是对发送的数据进行了包装(多了表示各种属性的报头)
此链接可以学习以下编写http服务器:超轻量型http服务器 tinyhttpd
2、环境
本人电脑配置了apache+php的开发环境,使用80端口
3、代码
client
// ConnectToPHPServer.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <stdio.h>
#include <winsock.h>
#include <string.h>
#pragma comment(lib, "ws2_32.lib")
#define PORT 80
#define SIZE 512
#define MAX_SIZE 1024
void buildGETHeader(char* header, int size, char* host, char* res)
{
memset(header,0,size);
strcat(header,"GET ");
strcat(header,res);
strcat(header," HTT