I have a file sharing application with logging capabilities. Every time a user connects, the client sends a string telling that a user is connected, same also when a client disconnects a string, telling that the user was disconnected is sent on the server.
Now my problem is, there is a possibility that when a user connects or disconnect then at the same time is sending a file, the program will not be able to guess which data is for the logging part and which data is for the file sharing part. What I want is to separate them without interrupting each other. The TCP connection is implemented in a single TCP socket, now I'm thinking that, maybe using a separate socket for either of the two functionality can solve the problem. Or maybe some kind of algorithm to determine the type of data sent, whether its a file data or a string. Something that involves the IO library and stuffs like that. My friend told me, that maybe we can try getting the file name of the file being sent and then compare it to the string sent for the logging part. The strings sent for the logging part is constant, so that should be possible, I guess?
I got some ideas running in my head but I think there are better ways to do this. Any suggestions?
Thanks in advance!