分享到plurk 分享到twitter 分享到facebook

版本 21dfa0f701b70d545b3e60b8bff26e643f3c2f64

embedded/2016q1h3

Changes from 21dfa0f701b70d545b3e60b8bff26e643f3c2f64 to 71f343e6c1cf657b7e1b79fc3a3079e1caf17fae

---
title: 2016q1 Homework #3
toc: no
...

預期目標
------------
- 學習多執行緒程式開發
- 應用物件導向程式開發方法
- 透過 Doxygen 自動建立技術文件
- 培養專業程式開發風格

預先安裝的套件
------------
```
$ sudo apt-get install apache2-utils check
$ sudo apt-get install doxygen graphviz
```

Server Framework in modern C
-----------------------------
* [server-framework](https://github.com/embedded2016/server-framework): 用 C99 撰寫、具備物件導向程式設計風格的伺服器開發框架
* 由三部份組成:
    - [async](https://github.com/embedded2016/server-framework/blob/master/async.h)
    - [reactor](https://github.com/embedded2016/server-framework/blob/master/reactor.h)
    - [protocol-server](https://github.com/embedded2016/server-framework/blob/master/protocol-server.h)
* 取得原始碼並編譯:
```
$ git clone https://github.com/embedded2016/server-framework.git
$ cd server-framework
$ make
```
* 測試 [async](https://github.com/embedded2016/server-framework/blob/master/async.h)
```
$ ./test-async
```
    - 預期將看到類似以下輸出:
```
wrote task 8190
wrote task 8191
Hi! 16377
Hi! 16378
# signal finish at (711.426132) ms
# elapsed time: (711.728594) ms
```
* 測試 [reactor](https://github.com/embedded2016/server-framework/blob/master/reactor.h)
```
./test-reactor
```
    - 預期將看到以下訊息:
```
Serving HTTP on 127.0.0.1 port 8080
now open up the URL http://localhost:8080 on your browser
```
    - 依據指示,在網頁瀏覽器裡頭打開網址 `http://localhost:8080`,將會看到 "Hello World!" 字樣
    - 回到原本執行 `./test-reactor` 的終端機視窗,按下 `Ctrl-C` 以結束程式