



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




CMSC 212 โ F05 (lect 18)^1
Announcements
CMSC 212 โ F05 (lect 18)^2
Events
CMSC 212 โ F05 (lect 18)^3
Event Driven Programming
CMSC 212 โ F05 (lect 18)^4
Structure of an Event Driven Program
CMSC 212 โ F05 (lect 18)^7
Why select for writing?
CMSC 212 โ F05 (lect 18)^8
Select Example
int main() { int ret, myServerFD, FD2, maxFd = 0; FD_SET set; myServerFD = connectToServer(); FD2 = connectToServer(); while (1) { maxFd =0 ; FD_ZERO(&set); FD_SET(0, &set); FD_SET(myServerFD, &set); if (myServerFD > maxFd) maxFd = myServerFD; FD_SET(FD2, &set); if (FD2 > maxFd) maxFd = myServerFD; ret = select(maxFd+1, &set, NULL, NULL, NULL); if (ret) { if (FD_ISSET(0, &set)) { /* read from standard input / } if (FD_ISSET(myServerFD, &set)) { / read from net / } if (FD_ISSET(FD2, &set)) { / read from other net */ } } } }
CMSC 212 โ F05 (lect 18)^9
CMSC 212 โ F05 (lect 18)^10