The program is a chat server, it receives a message from one client and sends the message to everyone connected to this server. The vector v3 contains the user name selected by the client. I just want to send the info of connected users to the server with the message. Is there any way I can send both the vector v3 and the user name to everyone, while not mixing them both? Or do I have to mix them somehow?
I'll try to use ArrayList for the program, but first let the logic complete, thanks for the suggestion
You are using a datagram socket; as far as I know, it just takes a stream of bytes and tries to deliver them to the specified address. It is up to the program receiving this data to do something intelligent with it; if you were to call toString on your Vector and pass that string into the socket, it will take it and transmit it, but the program getting that data must know how to tell the difference between it and anything else that comes.
If you send messages from party A to party B, for instance, perhaps that's just a(nother) String. The receiving program is not told that messages were written into the socket separately from Vectors, or from other messages, etc. It is up to the receiving program to know how to tell where one set of data ends and the next one starts. So you can create delimiters, counts of characters being sent, labels and tags, etc., it's all up to you. But the socket on the receiving end doesn't keep track of all that, to the socket it's just a stream of bytes.
Incidentally, a program can LOOK like these things are being delimited while being tested, because you don't have several of the messages being sent at one time. But it will fail when you do.