I’m making a program in C++ using windows sockets where I want a single socket but the ability to send data from different threads and distinguish server side which thread sent the data as they have different applications. Essentially logical data streams using a single socket connection. I’m having trouble finding a way to differentiate the packets server side. The best I can think of is starting each packet with a few bytes indicating which thread has sent it. Are there any better ways to be doing this?
Similar to How to use single port for multiple logical data streams (Winsock)? but I'm stuck at differentiating the packets.