Bug fix for select() usage

This commit is contained in:
Tristan B. Velloza Kildaire 2022-05-10 15:11:50 +02:00
parent 2be8a80a07
commit a51c593e61
1 changed files with 5 additions and 1 deletions

View File

@ -59,7 +59,7 @@ public final class Watcher : Thread
{
/* We acre about `endpoint` status changes */
socketSetR = new SocketSet();
socketSetR.add(endpoint);
socketSetW = new SocketSet();
socketSetE = new SocketSet();
@ -78,6 +78,9 @@ public final class Watcher : Thread
/* The message's data */
byte[] receivedMessage;
/* We want to check if `endpoint` can be read from */
socketSetR.add(endpoint);
/* Check if the endpoint has any data available */
int status = Socket.select(socketSetR, socketSetW, socketSetE, timeOut);
@ -100,6 +103,7 @@ public final class Watcher : Thread
if(socketSetR.isSet(endpoint))
{
/* Do nothing (fall through) */
}
/* We have an error */
else