I have a multi-threaded server that handles client requests, and makes new threads for each one that is connected. This is working great and I am able to send "text" messages back and forth to the server without a problem. Like a chat system.
Now I have in mind a way to be able to send files across these client connections to the server, but every single example I see in java always has a hard-coded file name on server / client side - but I want to set my own for flexibility. And I would love if it were not only able to not only receive files but also receive "text" messages on the same port simulatanously.
I have an idea whereby the "text" message port I have at the moment, tells the server a file is going to be sent from a client, then the server opens up a "file transfer" port, just for file transfers. That way the "text" port could specify the name etc of the file. And the other port could send the files quite happily, without interruption.
Does anyone know a better way to do this though? I don't really want to use two ports, it seems a bit messy. I would prefer to make a separate thread on the server side to deal with the file transfer and also deal with "text" message at the same time, if this is even possible?
Thanks in advance, I hope I have been clear enough :)