11.01.2015 Views

I/O Multiplexing: select and poll

I/O Multiplexing: select and poll

I/O Multiplexing: select and poll

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

用 <strong>select</strong> 改 寫 str_cli<br />

• 上 一 章 的 str_cli 用 兩 個 system calls 分 別<br />

取 得 input<br />

–fgets 用 於 stdin 的 user input<br />

–readline 用 於 socket input<br />

均 為 Blocking I/O<br />

• 這 樣 沒 有 辦 法 同 時 等 待 兩 個 inputs。 因 此<br />

當 client 等 在 fgets 時 , 無 法 同 時 取 得<br />

socket input 進 來 的 資 料<br />

• 本 章 改 用 <strong>select</strong> 來 同 時 等 待 兩 個 inputs<br />

14

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!