How to use sockets?

Björnke von Gierke bvg at mac.com
Sun Nov 7 18:57:50 EST 2004


On Nov 07 2004, at 23:46, 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
> grum

note: this is the hard way, with datagramm sockets its way simpler, but 
that's the way i would do it :)

--server button:
on mouseUp
   accept connections on port "8181" with message "incomming"
end mouseUp

on incomming remoteIP
   read from socket remoteIP until return with message "gotOne"
end incomming

on gotOne remoteIP theMessage
   put theMessage  into field "Your field here"
   close socket remoteIP
end gotOne

--client field:
on returnInfield
   open socket "localhost:8181" with message "contacted"
end returninfield

on contacted theIP
   write the text of me & return to socket theIP
end contacted

<>()<>()<>()<>()<>()<>()<>()<>()<>()<>()<>

official ChatRev page:
http://chatrev.cjb.net:8080

Chat with other RunRev developers:
go stack URL "http://homepage.mac.com/bvg/chatrev1.2.5.rev"



More information about the use-livecode mailing list