I creating an application in visual studio where I have a client to request specific information to multiple servers. Someone Knows i can make this communication? For one server i know to create that, for many servers i dont have idea. Code example!!! One client for many servers!

For one server i have this code:

Try
     client.Connect(IPAddress, PortNum)
     RichTextBox1.Text() = "Connection is Accepted"
     Catch ex As Exception
      RichTextBox1.Text() = "Connection is Failed"
End Try

Recommended Answers

All 3 Replies

The solution i founde , for curiosity was as follow:

Private Sub pesquisa_e_conecta_ips_portas()
        Dim id(50) As Integer
        Dim ip(50) As String
        Dim porta(50) As Integer

        Dim max_colum As Integer = DataGridView1.RowCount - 1

        For i As Integer = 0 To max_colum
            id(i) = CInt(DataGridView1.Item(0, i).Value)
            ip(i) = CStr(DataGridView1.Item(1, i).Value)
            porta(i) = CInt(DataGridView1.Item(2, i).Value)
        Next


        For k As Integer = 0 To max_colum
            Try
                FX_client = New TcpClient
                FX_client.Connect(ip(k), porta(k))
                'MessageBox.Show("OK!!!     " & ip(k))
                Timer1.Start()
                analisa_estado_dos_postos(k)
            Catch ex As Exception
                'MessageBox.Show("NOT OK!!!     " & ip(k))
            End Try
            FX_client.Close()
        Next
    End Sub

So , i create a datagridview for that case, and i see how many ip's i have to connect. Next, i conect one by one into the cicle for. After that i call the time to do this repeatly.

Very good. Please mark the thread as solved. Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.