recv ohne Blocking-Call
-
Hallo. Ich suche gerade eine Möglichkeit recv als NON-Blocking Aufruf zu verwenden. Das ganze soll jedoch ohne zusätzliche Threads laufen. Ich wollte einfach erreichen, dass beim Aufruf von recv geprüft wird ob Daten vom Server angekommen sind andernfalls soll das Programm halt etwas anderes machen. Weder bei Google noch mit der Forumsuche habe ich bisher etwas gefunden. Vielen Dank allen Helfenden.
-
Schau dir mal man: select(2) an, damit kannst du genau das abfragen.
-
dann such mal nach select.
-
$ man recv
If no messages are available at the socket, the receive calls wait for
a message to arrive, unless the socket is nonblocking (see fcntl(2)) in
which case the value -1 is returned and the external variable errno set
to EAGAIN. The receive calls normally return any data available, up to
the requested amount, rather than waiting for receipt of the full
amount requested.Geholfen?
mfg, KdeE
edit: *rofl*
-
Danke euch allen. Select ist genau das was ich gesucht habe.