SimpleWebServer

From AdvancedHMI
Jump to: navigation, search

This is a VERY basic component that sends a screen shot of an AdvancedHMI form to a web browser.

To use:

1) From the Toolbox place the SimpleWebServer on the form
2) Set the TCPPort property to 8080 (This can be left at 80 if you know for sure there is not already a web server on your PC)
3) Set SourceForm property to the form you wish to display
4) Start the application
5) In a web browser, enter the IP address of your PC along with the port number

  http://192.168.1.111:8080


It can be tricky to make it work. If it doesn't work there are 2 likely possibilities. The first is that it attached itself to another Ethernet port than the one you specified the IPAddress. To troubleshoot this:

1) In Solution Explorer, expand down the AdvancedHMIControls project
2) Expand down the Components folder
3) Right click the SimpleWebServer.vb and select View Code
4) Go to approximate line 107 and look for this code:

       Try
           server = New TcpListener(localAddr, m_TCPPort)   <-- place break point here
           server.Start()
           server.BeginAcceptTcpClient(AddressOf ConnectionAccepted, server)
       Catch e As SocketException
           Console.WriteLine("SocketException: {0}", e)
       End Try

5) Click in the left margin to place a break point next to the line after "server = New TcpListener(localAddr, m_TCPPort)"
6) Run the application
7) When it stops at the breakpoint, hover over localAddr and see what the IP address is
8) Use the address in your browser along with the port number as shown above


The other common problem is a port conflict. When starting the application, check the Visual Studio output window to see if it shows a Socket Exception.