socket connection

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
adventuresofgreg
Posts: 349
Joined: Tue Oct 28, 2008 1:23 am
Contact:

socket connection

Post by adventuresofgreg » Thu Jan 19, 2017 2:00 pm

I'm having trouble making a socket connection from a Livecode server to a livecode standalone (message receiver) running on the same machine.

My Livecode server is running in a LINUX DOCKER CONTAINER ON a local mac. I have verified that the socket connection on the standalone works (if I put the LC server code into another standalone running on the local machine, it connects to the "message receiver" and sends the message correctly.)

LC server code:

Code: Select all

<?lc put "<em>Hello World!<em>" -- just a test to make sure the server is working, and it is.
open socket to "localhost:8080"
write "hey there!"  to socket "localhost:8080"
close socket "localhost:8080"
 ?>
Standalone "message receiver" code:

Code: Select all

global tSocket

on mouseUp
   put "8080" into tSocket
  accept connections on port tSocket with message "someoneConnected"
end mouseUp

on someoneConnected tSocket
  read from socket tSocket until return with message "newMessage"
end someoneConnected

on newMessage theIp theMessage
   put  theMessage & return after field "mytext"
   read from socket tSocket until return with message "newMessage"
end newMessage

Post Reply

Return to “Talking LiveCode”