1
Network / Re: What is the best way to constantly communicate with multiple sockets?
« on: October 28, 2024, 05:35:39 pm »
Thanks for the help! I still have one question though.
I understand that there needs to be an open TCP socket on both the client and the server for communication, and both have to exist for actual communication. Currently, on my server side, I am using a function to check for incoming connections and receive the message (I have currently implemented opening and closing the socket per request as a placeholder). This function is run every time window loops.
My question is, if I keep the socket open while window loops and potential accepts more connections, is it actually possible for all of these connections to stay open? Like I said, it is just one function, so there is only one listener and socket that are running every window loop. To my understanding, every time the function loops, the existing connection is destroyed (like I said, only one client) in order to make way for a new connection. Is this actually the case, or am I misunderstanding how this works?
If this is too confusing, could you provide a code snippet of what storing the socket pointers would look like? I am currently struggling to grasp this concept for some reason.
Thank you for your help! Sorry that I responded this late.
I understand that there needs to be an open TCP socket on both the client and the server for communication, and both have to exist for actual communication. Currently, on my server side, I am using a function to check for incoming connections and receive the message (I have currently implemented opening and closing the socket per request as a placeholder). This function is run every time window loops.
My question is, if I keep the socket open while window loops and potential accepts more connections, is it actually possible for all of these connections to stay open? Like I said, it is just one function, so there is only one listener and socket that are running every window loop. To my understanding, every time the function loops, the existing connection is destroyed (like I said, only one client) in order to make way for a new connection. Is this actually the case, or am I misunderstanding how this works?
If this is too confusing, could you provide a code snippet of what storing the socket pointers would look like? I am currently struggling to grasp this concept for some reason.
Thank you for your help! Sorry that I responded this late.