1
Network / Re: Waiting for an incoming message for a certain time.
« on: February 21, 2019, 06:06:49 pm »
I wrote this, but im not sure, if it will work. (Its a running thread!).
void getPoints(TcpSocket* client, int *points) {
char rec[100];
size_t received;
int i;
client->setBlocking(false);
while (client->receive(rec, 100, received) == Socket::NotReady && i < 5000) {
sleep(milliseconds(10));
i++;
}
if (strlen(rec) != 0) {
*points = atoi(rec);
}
}
char rec[100];
size_t received;
int i;
client->setBlocking(false);
while (client->receive(rec, 100, received) == Socket::NotReady && i < 5000) {
sleep(milliseconds(10));
i++;
}
if (strlen(rec) != 0) {
*points = atoi(rec);
}
}