Issues using TCPSocket on web page

I am converting a desktop app to a web app. Both programs communicate through TCP sockets with a third (host) program that uses a Serversocket. There are no problems with the desktop app, but I have two issues with the web app. Since I cannot add a TCPSocket to the webpage as I did on the desktop app, I subclassed TCPSocket and put my code in the DataReceived event.

  1. I have been unable to get the value obtained with ReadAll to appear on the web page. The autocomplete works when I enter myPage.myContainer.myTextFld.Text but I get a nil object exception when the code runs. The same thing happened when I tried Session.myPage.myContainer.myTextFld.Text. Autocomplete did not work when I entered just the text field. I am at a loss as to how to reference objects on a webpage from a TCPSocket.

  2. On the desktop app, after I connect to the host program, soc.IsConnected returns True. On the web app, it returns False. That threw me for a while until I discovered that it was sending the request and the host was responding despite not being connected.

The problem you are running into is that sockets run on the main thread and have no connection to any particular session. There are a couple of ways you can handle this:

  1. When you create the tcpsocket, store a property with the id of the current session on it and later use WebSessionContext to reconnect to the session.

  2. Have the socket write it’s results into a property and then use a WebTimer to retrieve the data.

Thanks Greg. Should I file a bug report about the IsConnected always returns false?