dont poll
that will suck up a ton of CPU and block your app in other ways
tcp sockets can be event driven
you just need to handle the events they provide for dataavailable etc
and you can do this in many different ways
in a GUI program drag an instance onto a layout & add the events
use addhandler & removehandler to handle the events
create a subclass that handles the events and then create instances of these in your application code
So I can not use 1) I assume (no way to drag tcpsocket into the layout).
The server App I am trying to communicate with (a card game) is not build with Xojo (but pure basic) and uses TCP to talk to the client. There are clients for linux, windows and macOS already. We are trying to build a web interface / web client, so that users do not need to download a client software.
As said I am able to connect and send messages synchron to the server. Now I need to figure out how to asynchronous check if there is something new from the server.
Could this be done, using a timer for example to check each xx ms for new data?
yeah DONT use a timer
you’re almost guaranteed to miss data
the asynchronous way is to implement the events
if you cant drag one onto a layout you can still use the async method you just have to use #2 or #3 as I mentioned
#2 is pretty easy since all you really do is write a method that will be called when the event is raised by the framework (instead of adding the event to an instance on a window)
And then you can get data from the socket asynchronously
Slightly shameless plug, but on the otherhand it is related to the OP’s question… I have a client socket code (it’s a little in flux, but it is 100% in the public domain) that you can take a look at… Any questions, feel free to message me on here (either in private or in this thread)