Make a cheap web server with Revolution read write on port 80

Jean Marc Delorme jm.delorme at wanadoo.fr
Wed Apr 30 02:30:13 EDT 2008


Hi from France!

The idea of this cheap html server came from "chat server" demo stack.
I tried, it works quite fine, and I use it for a true web service 
(carpooling).

Next is a simplified sum-up:

On Openstack
.  accept connections on port 80 with message GotAConnection

on GotAConnection aSocket
.  read from socket aSocket for 1 line
.  analyze received line (GET or POST)
.  read from socket aSocket with message GotNextLines

on GotNextLines aSocket , ReceivedLines
.  Analyze ReceivedLines
.  Do any processing you want with the user request
.  Make TheHtmlAnswer from pre-made file + replaced text (wanted GET file ou
POST answer)
.  if complete message received then write TheHtmlAnswer to socket else read 
again

Any distant web browser then gets the requested .html files (as forms with 
submit buttons), or POST anwsers after button clicks (submits) in previous 
sent forms.

Is'nt life easy?
The only limit is that only html text is replied (no image) because no 
Apache server is used.
Also have to record socket connections context in a gSocketConnectionsTable 
because many connections are available (which .htm file must be sent back 
when GotNextLines?).
Thank you for your feedback and own return on experience about making a web 
server from Revolution.

Jean-Marc Delorme, operations manager
 www.ecovoiturons.org , Ecovoiturons = let's use carpool against global 
warming


----- Original Message ----- 
From: <rgould8 at aol.com>
To: <use-revolution at lists.runrev.com>
Sent: Wednesday, April 30, 2008 4:15 AM
Subject: [Norton AntiSpam] Reading from Sockets


>
> If I have a webpage that has a link like this:
>
> <a href="127.0.0.1:77">Talk to Rev</a>
>
>
> and while that webpage in Safari has that link clicked, I'd like to have 
> Revolution lurking in the background waiting for that click, can someone 
> tell me what I'd need to add to this script?
>
> on openCard
> ? open socket "127.0.0.1:77"
> ? read from socket "127.0.0.1:77" with message "gotdata"
> end openCard
>
>
> on gotdata
> ? answer "got data from the Safari webpage!"
> ? close socket "127.0.0.1:77"
> end gotdata
>
>
>
> I'm just a little confused about whether I need to _continually_ do the 
> "read socket" in a timer-loop, or if I can give it an infinite timeout.
> Right now, I don't get this to work at all, even when I click the link 
> within 5 seconds, so I'm obviously missing something important.?
>
>
>
>
>
>
> -----Original Message-----
> From: Bill Marriott <wjm at wjm.org>
> To: use-revolution at lists.runrev.com
> Sent: Tue, 29 Apr 2008 8:33 am
> Subject: Re: way to listen to port 127.0.0.1
>
>
>
>
>
>
>
>
>
>
> You're on the right track.
>
> If what you really need to do is to communicate with Rev from your web 
> page,
> you could set up Revolution as a very simple web server on a *different*
> port -- Safari will use port 80 by default -- and send it a command in the
> form of a URL or POST command. You don't want to have the two applications
> (Safari and Rev) stepping on each other, trying to use the same port.
>
> Andre Garzia's RevOnRockets has a basic web server implementation, but I
> don't know if you'd even need that fully-featured of a solution.
>
> http://www.andregarzia.com/RevOnRockets/
>
>> So, that puts me to Plan B:
>>
>> Since this is a touch-screen kiosk environment and I have full-control
>> over the hardware/software, I'd like to just use "SAFT", which is 
>> software
>> that makes Safari run in full-screen mode, and then have a silent version
>> of Rev running in the background waiting for it's cue.? When it receives
>> the cue, it needs to print some data to a thermal-label printer attached
>> to the kiosk.
>>
>> I am was hoping that I could have a javascript on a web-page that passes
>> data to 127.0.0.1:80, and then have my Rev app ready to receive that 
>> data.
>>
>> I'm not suceeding, however, and I could use some assistance with the
>> scripting.?
>>
>> Something like:
>>
>> open socket "127.0.0.1:80"
>> read from socket "127.0.0.1:80" with message "gotdata"
>>
>> and then on the web-page:
>>
>> a href="127.0.0.1:80">Click me to test sending a message to 
>> Revolution</a>
>
>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your 
> subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
>
>
>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your 
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
> 






More information about the use-livecode mailing list