I recently reviewed socket programming, which is used to help myself and everyone remember.
The socket Io model can manage the communication on the socket. The details are as follows:
1. Select model:
By placing the socket into the set and filtering by the Select function, you can obtain the IO activity on the socket.
2. Wsaasyncselect model:
Register the IO activity you are interested in to the corresponding socket. If this activity occurs, it will be sent to the specified form.
Register a message.
3. Wsaeventselect model:
Register the socket activity you are interested in to the corresponding socket. If this activity occurs, the specified event is changed to the notification Status. Wait for the event object and query the IO activity on the socket corresponding to the event.
The preceding sockets have the following commonalities:
1. You can manage multiple sockets in one thread.
2. After Io activity occurs on the socket, you must perform read/write operations synchronously (if reading a large amount of data is a problem ).
4. Overlapped model:
In the same way, I/O activities on the socket are obtained through the event notification mechanism. The difference is that the operating system helps us manage the data sending and receiving activities on the socket until the activity ends.
5. Completionport model:
similar to the overlapped model, the difference is that it provides a mechanism similar to the thread pool. After overlapping Io operations are completed, will call one of the threads waiting for the overlapping Io operation to complete. This model improves efficiency through underlying optimization of the operating system. At the same time, there is no limit for a single thread of the event kernel object to wait for 64 socket events.
it is a socket model required for online games.