原创 c++入門 (頭文件)

Definition of a class      類的定義1. In C++,seperated .h and .cpp file are us

原创 Tinyhttpd源碼學習(httpd.c)

接着上面,當path的本地文件沒有可執行權限時,認爲不是cgi程序,調用serve_file進行處理 void serve_file(int client, const char *filename) {     FILE *resou

原创 Tinyhttpd源碼學習(httpd.c)

繼續上一篇,寫startup方法,服務端socket的啓動過程 int startup(u_short *port) {     int httpd = 0; //-------------- server_sock的fd聲明    

原创 Tinyhttpd源碼學習(httpd.c)

因爲代碼有500行,相對較長,這裏不再按照源代碼的順序,而是按照調用關係,先main,後一個個方法展開 int main(void) {     int server_sock = -1; //----------該httpd的服務soc

原创 Tinyhttpd源碼學習(httpd.c)

寫完startup,下一個就是accept_request,這裏是處理請求的主要邏輯 void accept_request(void *arg) {     int client = (intptr_t)arg; //--------

原创 Tinyhttpd源碼學習(httpd.c)

當httpd運行時,對文件具有可執行權限時,則認爲該文件是cgi程序,調用函數 execute_cgi /*****************************************************************

原创 Tinyhttpd源碼學習(simpleclient.c)

這是我學習c/c++的第二個項目,做爲一個菜鳥,只會最基本的語法,很多都要標記出來。 #include <stdio.h> #include <sys/types.h> #include <sys/socket.h> #include

原创 c++入門 (Hello world)

第一個C++程序,Hello world #include <iostream> using namespace std; int main() {cout << "Hello,world!"<endl;return 0;} 這裏和

原创 c++入門 (成員變量)

Fields,parameters local variables.                1. All three kinds of va

原创 c++入門 (什麼是面向對象編程,理論)

oop的原則 1. 對象是data + operation.  外部對象不能直接訪問對象的data,可以調用對象的operation. 2. 對象是Entity, is an variable in programing language