Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get the IP address and port number assigned by .NET
    primarykey
    data
    text
    <p>I have two Windows Forms applications, one acts as server (that is, <strong>Winform:Server role</strong>) and another one as a client (that is, <strong>Winform: Client role</strong>). In my LAN setup, there are 6 PCs and these PCs connected to each other via a 8-port switch and each PC has more than one LAN card.</p> <p>There is one PC running [Winform: Server role] and five others running the [Winform: client role]. In <strong>[Winform: Server role]</strong>, I'm using following code to obtain the local <a href="http://en.wikipedia.org/wiki/IP_address" rel="nofollow">IP address</a> and port number and the <strong>[Winform: Server role]</strong> will listen to all incoming TCP requests according to this auto-assigned IP address and port number.</p> <pre><code>Dim Listener As System.Net.Sockets.TcpListener Dim Client As New System.Net.Sockets.TcpClient Dim Message As String = "" Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Listener = New System.Net.Sockets.TcpListener(System.Net.IPAddress.Any, 0) Listener.Start() End Sub </code></pre> <p>How do all <strong>[Winform: Client role]</strong> know my <strong>[Winform: Server role]</strong> IP address and port number at run time?</p> <p>I need to clarify my intention. My current approach to my intention maybe incorrect. I attempt to create a 'zero configuration client-server networking' and that is plug &amp; play. The server will know where the client and vise versa. I know there is a program (that is, MaxiVista) has done that exactly.</p> <p>MaxiVista has two applications, that is, server and client. Users only need to execute the <strong>server application</strong> in PC designated as server role and execute the <strong>client application</strong> in another PC designated as client role. Then the server will be able to find all executing clients in the same LAN.</p> <p>My intention is just that. Plug and play 'zero configuration client-server networking' within the same LAN.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload