Non-Blocking Sockets für Windows
-
Hallo,
welche Möglichkeiten für Non-Blocking Sockets gibt es unter Windows?
Für Linuxwelten finde ich jede Menge Dokumentationen zu select.Gibt es auch eine 1zu1 Bibliothek für Windows mit select()?
Ich brauche wirklich nur Ansatzpunkte, kein vorgekautes.
Danke,
/bin/laden
-
Boost.Asio
-
When a socket is created, by default it is a blocking socket. Under
blocking mode socket I/O operations, connect and accept operations all
block until the operation in question is completed. To change the socket
operation mode from blocking mode to non-blocking mode, you can either use
WSAAsyncSelect, WSAEventSelect, or the FIONBIO command in the ioctlsocket
API call.
WSAAsyncSelect maps socket notifications to Windows messages and is the
best model for a single threaded GUI application.
WSAEventSelect uses WSAEnumNetworkEvents to determine the nature of the
socket notification on the signaling event and maps socket notifications by
signaling an event. This is a useful model for non-GUI applications that
lack a message pump, such as a Windows NT service application.
The FIONBIO command in the ioctlsocket API call puts the socket into non-
blocking mode as well. But you need to poll the status of the socket by
using the select API.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms738573%28v=vs.85%29.aspx
//edit: Sollte am besten nach WinApi, vielleicht auch in die FAQ.
-
Dieser Thread wurde von Moderator/in SeppJ aus dem Forum C++ (auch C++0x, bzw. C++11) in das Forum WinAPI verschoben.
Im Zweifelsfall bitte auch folgende Hinweise beachten:
C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?Dieses Posting wurde automatisch erzeugt.
-
Es gibt doch select() unter Windows!?
WinSock bietet allerdings auch noch viel bessere Möglichkeiten als select()...http://tangentsoft.net/wskfaq/articles/io-strategies.html
Heuristic 2: Avoid select().