目錄表

網路程式設計: 作業三

0x01 作業描述

0x02 其他程式資料

0x03 實作心得與注意事項

write 需要檢查寫出去的狀況,在 non-blocking 的情況下,若 kernal 的 outgoing-data-buffer 則寫出去時會收到 return EWOULDBLOCK
Write to the client returns EWOULDBLOCK when server is slow

UNIX read 的回傳值為 0 時可視為 EOF 結束,但 windows 是有不同的 event driven,所以需要在 FD_CLOSE 的事件中去關閉 socket,不能像 UNIX 直接在 FD_READ 判斷 read 是否為 0,因為收到 EOF (read return 0) 只會發生在 FD_CLOSE event

若要連續兩次切割字串,需使用 strtok_r 取代 strtok,其中第三個參數 saveptr 會記錄目前切割到哪邊,所以該變數不可直接填 NULL
strtok