Difference between revisions of "SimpleWebServer"

From AdvancedHMI
Jump to: navigation, search
Line 30: Line 30:
 
7) When it stops at the breakpoint, hover over localAddr and see what the IP address is</br>
 
7) When it stops at the breakpoint, hover over localAddr and see what the IP address is</br>
 
8) Use the address in your browser along with the port number as shown above</br>
 
8) Use the address in your browser along with the port number as shown above</br>
 +
 +
 +
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.

Revision as of 14:52, 9 June 2019

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
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.