Fixed network library which also fixes RTL-TCP source

pull/991/head
AlexandreRouma 2023-02-09 16:55:37 +01:00
rodzic fd65984762
commit 16eaa0cf59
1 zmienionych plików z 10 dodań i 7 usunięć

Wyświetl plik

@ -148,18 +148,21 @@ namespace net {
// Create FD set
fd_set set;
FD_ZERO(&set);
FD_SET(sock, &set);
// Define timeout
timeval tv;
tv.tv_sec = 0;
tv.tv_usec = timeout * 1000;
int read = 0;
bool blocking = (timeout != NONBLOCKING);
do {
// Wait for data or error if
if (blocking) {
// Enable FD in set
FD_SET(sock, &set);
// Set timeout
timeval tv;
tv.tv_sec = 0;
tv.tv_usec = timeout * 1000;
// Wait for data
int err = select(sock+1, &set, NULL, &set, (timeout > 0) ? &tv : NULL);
if (err <= 0) { return err; }
}