Handling asynchronous sockets in WinSock?

I use the message box and WSAAsyncSelect. How can I track multiple sockets (clients) with a single message box?

+3
source share
2 answers

Windows supports several socket modes, and you need to clearly indicate which one you are using:

  • Blocking sockets. send and recv.
  • Non-blocking sockets: send and recv return E_WOULDBLOCK, and select () is used to determine which sockets are ready
  • Asynchronous Sockets: WSAAsyncSelect - Sockets send event notifications to HWND.
  • EventSockets: WSAEventSelect - socket signal events.
  • Overlapped Sockets: WSASend WSARecv OVERLAPPED. Overlapped Sockets IOCompletionPorts .

CAsyncSocket MFC.

, , WaitForMultipleObjects, 32.

IO CompletionPorts .


, Async Sockets :

  • FD "" , , , , .

  • GUI , : WM_TIMER WM_PAINT , . , , GUI SetTimer.

  • , GUI . , , - WM_APP .

  • FD - SocketObjects HWND, , WM_USER + , WASAsyncSelect. , WM_USER WM_USER + ( ), . WM_USER - 0x400, WM_APP - 0x8000, 31744 .

  • . , . .

  • HWND_MESSAGE -

+8

wParam , WSAAsyncSelect() , , . WSAAsyncSelect() :

s, hWnd wMsg. WParam . lParam . lParam . - , Winsock2.h.

0
source

Source: https://habr.com/ru/post/1792967/


All Articles