I have a client that basically wants to (from time-to-time) connect to a remote host send some messages and disconnect. But the host might not always be available. How do I set up a loop that does something like (preferably avoiding some constant cpu-time-consuming loops):
Attempt_Send_Data(DATA data)
Is the host online? No: Check again Yes: Connect, Transmit this data , Disconnect, return
(I am using C++ , WinSock2 and the TCP protocol)
On a totally unrelated note, but since I was working on it when you deleted your other question, I will post it here, and deleted as soon as you have had the time to take a look at it.
For other readers, yes, this is off-topic for this question, but maybe we need a messaging system of some sort.
for starters, refactor your
getInterSection
:Use like so: