HHTP CLIENT EXAMPLE *HTTP RFC SP: space (khoang trang) CRLF: \r\n REQUEST SYNTAX: Request = Request-Line *( general-header | request-header | entity-header ) CRLF [ message-body ] | HHTP CLIENT EXAMPLE HTTP RFC SP space khoang trang CRLF r n REQUEST SYNTAX Request Request-Line general-header I request-header I entity-header CRLF message-body Request-Line Method SP Request-URI SP HTTP-Version CRLF Method OPTIONS I GET I HEAD I POST I PUT I DELETE I TRACE I extension-method Request-URI I absoluteURI I abs_path Ex absoluteURI http pub WWW abs_path pub WWW HTTP-Version HTTP I HTTP EX GET http pub WWW HTTP Host or GET pub WWW HTTP include include define MY_PORT 80 define SERVER_ADDR define URL http transweb void makeRequestStr char buffer const char url const char host Examplee s GET http transweb HTTP r n s Host r n s Connection Close r n r n strcpy buffer GET strcat buffer url strcat buffer HTTP r n strcat buffer HOST strcat buffer host strcat buffer r n strcat buffer CONNECTION CLOSE r n r n u_long LookupAddress const char pcHost void error char msg int main int argc char argv WSADATA wsaData WSAStartup MAKEWORD 1 1 wsaData printf Client. SOCKET wsk socket AF_INET SOCK_STREAM 0 struct hostent hostname gethostbyname SERVER_ADDR struct sockaddr_in server_addr AF_INET LookupAddre ss SERVER_ADDR htons MY_PORT if connect wsk struct sockaddr server_addr sizeof server_addr 0 error ERROR connecting printf connected n Send REQUEST char buffer 1024 int n makeRequestStr buffer URL SERVER_ADDR send wsk buffer strlen buffer 0 GET RESPONSE printf Http content n recv wsk buffer 1024 0 buffer n 0 printf s n buffer closesocket wsk WSACleanup return 0 void error char msg printf s n msg exit 0 u_long LookupAddress const char pcHost u_long nRemoteAddr inet_addr pcHost if nRemoteAddr INADDR_NONE pcHost isn t a dotted IP so resolve it through DNS hostent .