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.

}<br />

}<br />

if (FD_ISSET(sockfd, &rset)) { /* socket is readable */<br />

}<br />

if (Readline(sockfd, recvline, MAXLINE) == 0)<br />

err_quit("str_cli: server terminated prematurely");<br />

Fputs(recvline, stdout);<br />

if (FD_ISSET(fileno(fp), &rset)) { /* input is readable */<br />

}<br />

用 FD_ISSET 測 試<br />

裝 置 是 否 ready<br />

用 FD_ISSET 測 試<br />

裝 置 是 否 ready<br />

if (Fgets(sendline, MAXLINE, fp) == NULL)<br />

return; /* all done */<br />

Writen(sockfd, sendline, strlen(sendline));<br />

<strong>select</strong>/strcli<strong>select</strong>01.c<br />

User 按 了<br />

Ctrl+D<br />

18

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

Saved successfully!

Ooh no, something went wrong!