Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to communicate between two VB.NET applications over the network
    text
    copied!<p>I am programming in VB.NET.</p> <p>I would like to sent a String or an Integer from a VB.NET application to another VB.NET application on different computers.</p> <p>I looked at some tutorials, but all the tutorials work only on the local network, and I want it to work over the Internet.</p> <p>This is my code for local connections:</p> <pre><code>Dim Listener As New TcpListener(34349) Dim Client As New TcpClient Dim Message As String = "" Private Sub Timer1_Tick(ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles Timer1.Tick If Listener.Pending = True Then Message = "" Client = Listener.AcceptTcpClient() Dim Reader As New StreamReader(Client.GetStream()) While Reader.Peek &gt; -1 Message = Message + Convert.ToChar(Reader.Read()).ToString End While RichTextBox1.ForeColor = Color.Black RichTextBox1.Text += Message + vbCrLf End If End Sub Private Sub btnSend_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles btnsend.Click If txtName.Text = "" Or cmbAddress.Text = "" Then MessageBox.Show("All Fields must be Filled", _ "Error Sending Message", _ MessageBoxButtons.OK, _ MessageBoxIcon.Error) Else Try Client = New TcpClient(cmbAddress.Text, 34349) Dim Writer As New StreamWriter(Client.GetStream()) Writer.Write(txtName.Text &amp; " Says: " &amp; txtmessage.Text) Writer.Flush() RichTextBox1.Text += (txtName.Text &amp; " Says: " &amp; txtmessage.Text) + vbCrLf txtmessage.Text = "" Catch ex As Exception Console.WriteLine(ex) Dim Errorresult As String = ex.Message MessageBox.Show(Errorresult &amp; vbCrLf &amp; vbCrLf &amp; "Please Review Client Address", "Error Sending Message", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End If End Sub </code></pre> <p><code>txtmessage.text</code> is the string I want to send.</p> <p><code>txtName.Text</code> is just a name of the sender</p> <p><code>cmbAddress.text</code> is the <a href="http://en.wikipedia.org/wiki/IP_address" rel="nofollow">IP address</a> of the remote computer</p> <p>How can I send data to another remote computer in VB.NET?</p>
 

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