Author Topic: SimpleWebServer problems  (Read 2059 times)

ddddd13

  • Full Member
  • ***
  • Posts: 118
    • View Profile
SimpleWebServer problems
« on: September 10, 2020, 07:01:07 PM »
I am trying to get SimpleWebServer to work. I looked on line and it showed how to diagnose connection problems, with a breakpoint. That is well and good if you are debugging the program, but after you have compiled it and try to run it on a different machine, it is a problem. I tried adding a consolewriteline to the SimpleWebServer code as follows.

        Dim LocalComputerName As String = System.Net.Dns.GetHostName() '* same as My.Computer.Name
        Dim localAddr As System.Net.IPAddress = GetIPv4Address(LocalComputerName)

        Console.WriteLine("address ", localAddr)
       
 If localAddr Is Nothing Then
            localAddr = System.Net.IPAddress.Parse("127.0.0.1")
        End If

But I never see anything. I have also tried.

Mainform.RichTextbox3.text=("address ", localAddr)

That gives me errors. Any ideas?

Dave

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: SimpleWebServer problems
« Reply #1 on: September 10, 2020, 09:44:10 PM »
You can probably benefit from this topic:

   https://www.advancedhmi.com/forum/index.php?topic=2630.0

ddddd13

  • Full Member
  • ***
  • Posts: 118
    • View Profile
Re: SimpleWebServer problems
« Reply #2 on: September 11, 2020, 10:00:15 AM »
Yes, I understand the break points, and I used them to diagnose the code and find the IP address on the computer the code was written on. However that does not help me with the computer the code will run on.

This would be a great candidate for a new component property, ActualAddress. I Envision a simple line of code

Richtextbox1.text=SimpleWebServer1.ActualAddress

This would show the actual IP address no matter what machine the program was running on.

Dave

ddddd13

  • Full Member
  • ***
  • Posts: 118
    • View Profile
Re: SimpleWebServer problems
« Reply #3 on: September 11, 2020, 11:47:34 AM »
I found the following online. It gets the IP addresses on the computer and displays them in Rich Text Box 3.

Code: [Select]

      Dim GetIPv4Address As String
        GetIPv4Address = String.Empty
        Dim strHostName As String = System.Net.Dns.GetHostName()
        Dim iphe As System.Net.IPHostEntry = System.Net.Dns.GetHostEntry(strHostName)

        For Each ipheal As System.Net.IPAddress In iphe.AddressList
            If ipheal.AddressFamily = System.Net.Sockets.AddressFamily.InterNetwork Then
                GetIPv4Address = ipheal.ToString()
            End If
            RichTextBox3.Text = RichTextBox3.Text & GetIPv4Address & vbCrLf
        Next
   

Dave

ddddd13

  • Full Member
  • ***
  • Posts: 118
    • View Profile
Re: SimpleWebServer problems
« Reply #4 on: September 11, 2020, 02:03:47 PM »
Now it leads me to another question. How would the following be able to find my computer as there may be  thousands of computers with that same ip address and port.

http://192.168.1.2:8080

Dave

MajorFault

  • Guest
Re: SimpleWebServer problems
« Reply #5 on: September 11, 2020, 07:07:43 PM »
You have 1000s of computers with the same IP in your network?!?

ddddd13

  • Full Member
  • ***
  • Posts: 118
    • View Profile
Re: SimpleWebServer problems
« Reply #6 on: September 11, 2020, 08:58:25 PM »
No. The idea is to be able to type in the web address on a cell phone to be able to see what is going on with the HMI. That is not the same network.

Dave

MajorFault

  • Guest
Re: SimpleWebServer problems
« Reply #7 on: September 11, 2020, 11:39:28 PM »
I understood the idea, trying to spur some thought. So, since you will only have one unique IP on your network, that's how you will find it.

MajorFault

  • Guest
Re: SimpleWebServer problems
« Reply #8 on: September 11, 2020, 11:41:04 PM »
You may want to look into hostnames.

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: SimpleWebServer problems
« Reply #9 on: September 12, 2020, 03:15:53 AM »
192.168 is classified as a private network.

Unless you are directly connected to that network, accessing it from public networks would require either a VPN or server to allow connecting to it.