Your scheduleAfter(100,Kodi3) needs to be called from within either onData or onClose function as it likely depends on data you are receiving from within Kodi or Kodi2 function?
I think there may be a misunderstanding on when certain functions execute in what you are developing.
Only the lines creating the socket and the actual connect function execute at the time kodi() is invoked.
The other functions such as onConnect, onData, onClose and onIOError execute after something has happened on a socket.
onConnect will be executed when the underlying socket connects to the server.
onData will be executed each time a block of data is available from the server.
onClose will be executed when the remote server closes the socket.
onIOError will be executed if there an an underlying socket error.
Once you understand that all these things don't execute at once but rather based on event triggers, you are one up in the game.
Next, if you are interested in why the above applies and why the examples do it this way...
I know you are trying to learn this on your own. The solution you require is complex and requires asynchronous programming expertise as well.
There are about 6 different items that are required for this solution.
4. Deep understanding of the HTTP protocol (using raw TCPSockets)
6. JSON Remote Procedure Calls (JSONRPC v2.0)
7. Creating an image from HTTP response data.
I offered to reach out to you via telephone for some pointers if need be. I don't think I got a response. The offer still stands as there is often alot that is lost in translation through a forum.
Last edited by Lyndel McGee on August 6, 2020 17:57.