Is it possible to send an array through a socket?
Hi,
We're students from Holland (18 years old) and we're trying to make a chat-program. Ofcourse a couple of problems have passed our way.
Our server and clients are connected via sockets, and in the client's interface we wanted a list with the names of the connected users. When the clients connect, their name is sent to the server and stored in an array. After that, this array (with all the names of the clients connected) should be sent to the client, who puts this array in a list.
Then my question: Is it possible to send this array through a socket to a client so this client can work with it? Is this the easiest way or should we look for an other way to do this?
Kind regards,
Marten & Niek
Re: Is it possible to send an array through a socket?
Quote:
Is it possible to send this array through a socket to a client so this client can work with it?
Yes
Quote:
Is this the easiest way or should we look for an other way to do this?
Well, you are storing users in an array, what happens when the number of online users increases! have you thought about that
Re: Is it possible to send an array through a socket?
How is this possible?
And we were thinking of every now and then the clients update the list... Or is there a more common way to do this?
Re: Is it possible to send an array through a socket?
I have no idea if there is a more common way. But I know that you can use Socket.getOutputStream() to transfer data from client to server and the other way
Re: Is it possible to send an array through a socket?
Ok, and do we have to transfer each value of the array (e.g. array[0], array[1], etc.), or is it possible to send the whole array at once?
Re: Is it possible to send an array through a socket?
I'm not sure if it's possible, you can always try.
Re: Is it possible to send an array through a socket?
Quote:
Originally Posted by Niekfct
Ok, and do we have to transfer each value of the array (e.g. array[0], array[1], etc.), or is it possible to send the whole array at once?
Have you considered using ObjectInputStream & ObjectOutputStream?