How to use sockets?
Andre Garzia
soapdog at mac.com
Sun Nov 7 18:58:37 EST 2004
On Nov 7, 2004, at 8:46 PM, DJ Grumble wrote:
> Hi,
>
> I am trying to make a simple chat client, however, I can't seem to get
> the socket scripts to work. Can anyone provide a quick sample script
> for sending the contents of a field (for the sender) and recieving the
> contents of a field (for the reciever?) I must be doing something
> wrong because I've read the docs 100 times.
>
> thanks
> grumble
DJ Grumble,
get ChatRev from Bjornke at http://chatrev.cjb.net:8080/
there show very good example of socket handling.
You should look for the accept connections command, this will "setup" a
server. I'll try a little script here, just to demo.... put all inside
a button, click the button.
------ Cut Here -----
on mouseUp
setupServer
end mouseUp
on setupServer
accept connections on port 8088 with message "newConnection"
wait 1 sec
revGoUrl "localhost:8088"
end setupServer
on newConnection theConnectionSocket
read from socket theConnectionSocket with message "finishedReading"
end newConnection
on finishedReading theConnectionSocket, theContent
put theContent
write format("HTTP/1.0 200 OK\nContent-Type: text/plain\n\nHello
World\n") to socket theConnectionSocket
close socket theConnectionSocket
end finishedReading
------ Cut Here -----
If this work (I am writing this as I write the email) you should have a
silly as hell Hello World HTTP Server running, also on your message box
you'll be able to see a nice HTTP Get Request. This should show how to
open, accept and handle a simple connection.
PS: this example is not full HTTP 1.0 compliant, I did not include
Content-Lenght nor Date headers... but I don't think your browser will
complain.
Cheers
andre
>
> _________________________________________________________________
> Is your PC infected? Get a FREE online computer virus scan from
> McAfee¨ Security.
> http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
>
--
Andre Alves Garzia ð 2004
Soap Dog Studios - BRAZIL
http://studio.soapdog.org
More information about the use-livecode
mailing list