Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sat Dec 15, 2018 4:15 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Get rest of URL?
PostPosted: Tue Aug 14, 2012 12:43 pm 
Offline

Joined: Wed Mar 01, 2006 6:48 pm
Posts: 199
I'm sure there is a way and I spent about 30 minutes searching but I cannot seem to find what I remember reading before.

I have a small app that starts listening with a standard TCPSocket on port 7777.

From a browser I can connect to: 127.0.0.1:7777 and all is happy. The connection is made and the little app sends back a web page.

I seem to remember there is a way in RB, either using a different socket type or a call to accept something like:

127.0.0.1:7777/test or 127.0.0.1:7777?test

What I want to do is in my "Connected' method detect that "test" has been passed on the URL and act upon it.

I apologize but I've been buried in PHP for the last month so I'm struggling to get my mind back around RB and how to do this. Do I need to use a different socket type?

Basically I'm making a small webserver that does specific things. IE connecting to:

http://127.0.0.1:7777 Will paint a status display
http://127.0.0.1:7777/on4 Might turn output #4 on (a fan or something)

So I need to grab the remaining part of the URL and parse it. I'd appreciate a pointer in the right direction.

Thanks in advance.

Mark

_________________
Colorado, USA
Primary: BioMedical/Custom Applications - www.sysdyn.com
Secondary: Handheld/Custom Applications - www.mrhswco.com


Top
 Profile  
Reply with quote  
 Post subject: Re: Get rest of URL?
PostPosted: Tue Aug 14, 2012 12:57 pm 
Offline
User avatar

Joined: Sat Nov 11, 2006 2:43 pm
Posts: 1221
Location: This poster has left the forums
This is in the web server demo.

In a TCPSocket listen for the DataAvailable event, read it all in to a string called 'theHeaders' for example. Then parse out the Header:

temp = nthField( theHeaders, chr(13), 1 )
cmd = nthField( temp, " ", 1 )
param = nthField( temp, " ", 2 )

in your example you are looking for cmd to equal "GET" and param to equal "on4"

I have a Real Studio based web server that opens two electric gates, controls a PTZ camera, activates a dog shock collar, and streams 9 IP based cameras. It is all based on the idea you describe

_________________
%Invalidforumsignatureexception% user signature not found


Top
 Profile  
Reply with quote  
 Post subject: Re: Get rest of URL?
PostPosted: Tue Aug 14, 2012 1:02 pm 
Offline

Joined: Wed Mar 01, 2006 6:48 pm
Posts: 199
Aw crap... The one method I didn't try... Ya I now remember reading that. Thank you so much.

I will tell you... PHP is fun but now I'm typing in semi colons behind every line in RB.

Have a great one!

_________________
Colorado, USA
Primary: BioMedical/Custom Applications - www.sysdyn.com
Secondary: Handheld/Custom Applications - www.mrhswco.com


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group