Yes, you need to store the connected clients. For example, it could be the instances of
TcpClient
obtained as a result of a call to
System.IO.Sockets.TcpListener.AcceptTcpClient
or instances
Socket
obtained as a result of a call to
System.IO.Sockets.TcpListener.AcceptSocket
:
http://msdn.microsoft.com/en-us/library/vstudio/system.net.sockets.tcplistener.accepttcpclient[
^],
http://msdn.microsoft.com/en-us/library/vstudio/system.net.sockets.tcplistener.acceptsocket[
^].
You could have two separate threads on the server side, one accepting new clients, another sending/receiving data. You will need to use thread synchronization at the access to this collection. However, never use
ArrayList
. This collection was rendered obsolete as early as of .NET Framework v.2.0, when generic were developed. It was not marked obsolete formally only because it would be find for support of legacy code, but for new development it makes no sense at all; it us more error-prone than generic collections. Use the collections of
System.Collections.Generic
.
Sorry if this answer is a duplicate on my previous answer,
Passing value from javascript to PHP ( Hidden Field )[
^].
I'm only adding some detail.
Now, it does not matter where the data is transmitted, from client to server or server to client. Usually, this is an alternative direction, like in a dialog: request-response, and both can carry some information, not only just the confirmation. This is a matter of your
application-layer protocol:
http://en.wikipedia.org/wiki/Application_layer[
^].
Even if you don't call it "protocol", such protocol always exist de-facto, explicit or implied.
—SA