TCP socket connection

Hey
I am trying to create a web app that will display data and the way i need to get the data is through a separate desktop app. I am trying to connect the apps with a TCP socket but for some reason I cannot connect. The web app is on the Xojo cloud, I designated a port to get through the cloud’s firewall for incoming data. I also have a TCP socket listening for commands in the web app, and I have the correct address and port in the desktops TCP socket to send the data. Any suggestions of what I can do to get socket to connect? Any suggestions will be appreciated Thanks.

Use an HTTP socket instead and talk to the web app’s HandleSpecialURL event.

So I got the HandleSpecialURL event to work. But I am having trouble connecting the Desktop app to the web app. Should I have the socket listener in the HandleSpecialURL event or the actual webpage? Also in the desctop app should I have a loop that will continually try to connect when the IsConnected is false? Thanks

In HandleSpecialURL, there is no webpage. Whatever you write out is what will be returned to the desktop app. And there is no connection. It’s a simple http request. You send the request, you get some text back, usually html, but it doesn’t have to be.

Thanks, that helps, but the language reference example for HandleSpecialURL confuses me. The example seems to be using a webapp to generate a random number, then calls another webapp with a URL that triggers the second app’s HandleSpecialURL, which sends back the random number embedded in HTML code to the first app. Is that what is going on?
Can a session be established in a desktop app that would allow using its identifier to call HandleSpecialURL in a web app?

[quote=125190:@David Graham]Thanks, that helps, but the language reference example for HandleSpecialURL confuses me. The example seems to be using a webapp to generate a random number, then calls another webapp with a URL that triggers the second app’s HandleSpecialURL, which sends back the random number embedded in HTML code to the first app. Is that what is going on?
Can a session be established in a desktop app that would allow using its identifier to call HandleSpecialURL in a web app?[/quote]

Any app that is capable to go to a particular URL is able to access a web app Specialurl : desktop, web app, browser …

Basically, HandleSpecialURL fires when you go to a specific URL such as /special/quote, and then you send whatever you want. The serial thing is an example of how you prevent misuse of your web service.

See /Xojo 2014 Release 2.1/Example Projects/WebQuoteService-SpecialURL.xojo_binary_project

[quote=125190:@David Graham]Thanks, that helps, but the language reference example for HandleSpecialURL confuses me. The example seems to be using a webapp to generate a random number, then calls another webapp with a URL that triggers the second app’s HandleSpecialURL, which sends back the random number embedded in HTML code to the first app. Is that what is going on?
Can a session be established in a desktop app that would allow using its identifier to call HandleSpecialURL in a web app?[/quote]
The example is a webpage that has a pushbutton that uses ShowURL to pass a random number to a special url. The output from HandleSpecialURL then replaces the webpage with another page that it just constructed.

The analogy to what you’re doing is your desktop app is the pushbutton on the page, and instead of the webpage being shown in a browser, the contents of that page - the html text - is returned to your desktop app.

Either way, something is calling the special url and receiving back some text. In the example, the browser gets the text. In your desktop app, it comes back to you as a string.

Michael, I just updated to 2014 2.1, but there is no WebQuoteService-SpecialURL file in the Example Projects folder, or Web subfolder that I can see.
Tim, so example in the Language reference appends session.Identifier in ShowURL because it is a web app? Since I won’t be calling ShowURL from a webapp I won’t need it?

Correct. You won’t be calling ShowURL either.

Ahh, so I make the request with HTTPSocket.SendRequest or Get, with /special/ in the URL string?

dim s as string = httpsocket1.get(“www.mysite.com/myapp/special/dosomething”, 30)

Thanks, we can now get data from the web app on Xojo cloud, but what we really want is to transfer data from a desktop on our network to the cloud app. Apparently we need to subclass HTTPSocket in order to handle the incoming events on the web app. But we can’t figure out how to do that.

You can use Post synchronously, too. Provide the timeout as in my previous example and you don’t have to worry about events.

dim s as string = "the stuff I want to send to my cloud app"
dim http as new httpsocket
http.SetPostData(s, "text/html")
dim result as string = http.Post("www.mysite.com/myapp/special/dosomething", 30)

Thanks, but the problem is that we don’t know how to access the data when it arrives in the web app, so we can display it there.