On the same port, you can connect unlimited number of clients to each listening socket of instance of
System.Net.Sockets.TcpListener
(limited by factors like available memory and the like). In this case, on each socket or
TcpClient
accepted by the server side, the server side obtains an instance of socket or
TcpClient
representing remote socket of the connected client. These instances can be used by a server side to send/recieve or write/read to/from the network stream (in case if
TcpListener
).
I don't know how to change your code just because I don't know your goal. However, the code you've shown does not look like having full sense. First of all, this is because you are not using threads. A server side needs two additional thread as minimum: one to accept new connections, another one to send/receive socket data or write/read to/from the network streams.
If you are trying to perform any blocking calls in your UI, consider you are done — it can never work properly.
Not clear why do you want to use Forms application for the server side. The adequate form of server-side application is a Windows Service. However, if you want to use the Form application for introductory experiments, research and/or prototyping, it's perfectly fine.
You can find some ideas I shared on this topic in my past solution:
Multple clients from same port Number[
^].
For threads working with UI (which is more typically developed on the client side), you need to use UI thread invocation. Please see:
Control.Invoke() vs. Control.BeginInvoke()[
^],
Problem with Treeview Scanner And MD5[
^].
For more on threading, please see my collection of my past solutions:
How to get a keydown event to operate on a different thread in vb.net[
^],
Control events not firing after enable disable + multithreading[
^].
—SA