The select Model
The select model is another I/O model widely available in Winsock. We call it
the select model because it centers on using the select function to manage I/O
. The design of this model originated on UNIX-based computers featuring Berkel
ey socket implementations. The select model was incorporated into Winsock 1.1
to allow applications that want to avoid blocking on socket calls the capabili
ty to manage multiple sockets in an organized manner. Because Winsock 1.1 is b
ackward-compatible with Berkeley socket implementations, a Berkeley socket app
lication that uses the select function should technically be able to run witho
ut modification.
The select function can be used to determine if there is data on a socket and
if a socket can be written to. The reason for having this function is to preve
nt your application from blocking on an I/O bound call such as send or recv wh
en a socket is in a blocking mode and to prevent the WSAEWOULDBLOCK error when
a socket is in a non-blocking mode. The select function blocks for I/O operat
ions until the conditions specified as parameters are met. The function protot
ype for select is as follows:
--
[0;1;35m�� ��源:��泉������ http://bbs.sdu.edu.cn [FROM: 202.194.32.132][m