I'm attempting to implement AVS connection in C using libcurl. I currently have my program setup to use a globally accessible multi_handle, so that any thread in the main function has access to it. I will very likely be modifying how I implement the curl_multi_perform into the program, but for now, I have it running in a loop so that it runs while there are still handles that have not finished their transfers. Since the downchannel connection stays open for a good stretch of time (should be the lifetime of the connection?), this is good for keeping the loop running in my early stage of the program.
I currently have a maximum of 3 connections running at a time, where I first establish the downchannel in a different thread than main, and then set up another thread to send a GET request to /ping every 280 seconds (decided that being just shy of 5 minutes may be a good for allowing headroom). What I am not sure of is is if these are all using the same/existing connection. I set up an easy handle for each one of these connections, and I begin to run multi_perform just after setting up the downchannel handle. I later loop multi_perform while transfers are incomplete closer to the end of the program. I also have set it so that the connection for the event (synchronize state) and ping connections are closed once they finish, so I am hoping that they all using the same connection as the downchannel has set up initially.
I notice that whenever I run the program, after the HTTP code (204 for both ping and POST of SynchronizeState), it says that it closes connection 1 and 2. I am curious if these are other connections are even related to connection 0 (aka the downchannel stream). Also, after about 10-15 mintues, the downchannel connection is cutoff, giving an error that data is not received from the server (unexpected EOF). Is this atypical for the downchannel to cutoff after such a time shorter than 60 minutes? I have made sure that my client will not end the connection until after about 65 minutes of inactivity. Does it sound like I am doing something horribly wrong here? Would these "nuances," per se, be enough to prevent my program from working? I am sure that I will need to change a few things to get my program into a proper working state, but I would like to know if my approach is even feasible.
I guess it is unclear to me how to keep the connection while closing and reopening streams. Thanks. Sorry if any of this is unclear.