I’m working on a multi-client/single-server application that uses UDP to communicate.
The reason for this is that I’m using multicasts and I’m streaming audio.
I haven’t got a lot of experience in UDP/TCP and I’m not really sure if it’s okay that I’m using several DatagramSockets with several different ports.
I have a couple of different objects that I need to send from one device to another, therefor I’m using one port for each type of object.
Is this okay? I already am using about 7 different ports now.
How can I use as minimum ports as possible?
With multiple clients and one server, you could have all clients send data to the same port on the server. The server would read all information from one socket (which is reading data on that port). Each client that sends data can send metadata along with each payload identifying the user, so the server can discern which received packet belongs to who. I actually think that you can already see the address that a packet comes from using built in functionality however. You could use these addresses to identify different clients, however down the road you might need a more robust solution to make your implementation more secure.