Making an ultra-simple Livecode server and client
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Making an ultra-simple Livecode server and client
Hi everyone, i'm new to this forum but i'm stuck trying to build a simple server. I'm trying to be able to have a client receiving a variable from the server when a button is clicked. But I don't know where to start. If anyone could help that would be brilliant.
-
- VIP Livecode Opensource Backer
- Posts: 10045
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Making an ultra-simple Livecode server and client
See the Chat Example included in the LiveCode install - in the IDE, click "Resources" in the toolbar, and you'll find the Internet Chat example near the bottom of the list in that window.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Making an ultra-simple Livecode server and client
Chat application :
http://forums.runrev.com/viewtopic.php?f=4&t=10761
Server / client, even easier :
http://forums.runrev.com/viewtopic.php? ... hat#p80132
http://forums.runrev.com/viewtopic.php?f=4&t=10761
Server / client, even easier :
http://forums.runrev.com/viewtopic.php? ... hat#p80132
Re: Making an ultra-simple Livecode server and client
Thank you very much for your replies, I have come up with some code, but it doesn't seem to work could someone possibly have a look at it and tell me what I am doing wrong.
This is the button that connects to the server:
This is the button that starts the server:
I am simply trying to get the field "got" to display "hello".
This is the button that connects to the server:
Code: Select all
on mouseUp
open socket "localhost" & ":*" with message "chatConnected"
end mouseUp
on chatReceived s,data
put data into field "got"
end chatReceived
on chatConnected s
read from socket s with message chatReceived
end chatConnected
Code: Select all
on mouseUp
local connected
accept connections on port * with message chatConnected
put s into connected
end mouseUp
on chatConnected s
write "hello" to socket connected
end chatConnected
-
- VIP Livecode Opensource Backer
- Posts: 10045
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Making an ultra-simple Livecode server and client
I think you'll need to specify a port number rather than attempt all with "*".
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Making an ultra-simple Livecode server and client
Yep, or just omit it completely if you can live with port 80FourthWorld wrote:I think you'll need to specify a port number rather than attempt all with "*".

From the docs about "socket":
...
Parameters:
host - The IP address or domain name of the host you want to connect to.
port - The port number you want to connect to. If you don't specify a port, port 80 is used.
(On most systems, port 80 is used for HTTP connections.).
...
Re: Making an ultra-simple Livecode server and client
I replaced the port I am using with a "*" for security purposes for when I was positing it on this forum. I do not know if it is safe to post which ports I am using online. Is it?FourthWorld wrote:I think you'll need to specify a port number rather than attempt all with "*".
Re: Making an ultra-simple Livecode server and client
Oh, sorry, we saw this as a "wildcard" 

-
- VIP Livecode Opensource Backer
- Posts: 10045
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Making an ultra-simple Livecode server and client
Are you testing on a local network, or is the server behind a different router? If the latter you'll need to set up port forwarding on the router to allow connections.
If you've already done that you may need to check the value of "the result" after the connection attempt to see if you can get more info about what's going on.
If you've already done that you may need to check the value of "the result" after the connection attempt to see if you can get more info about what's going on.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Making an ultra-simple Livecode server and client
Right, I think I found my problem, it comes from the client end,
I do not get the pop-up.
What am i doing wrong here?

By the way, I am using both programs on the same computer
Code: Select all
read from socket s with message chatReceived
answer "read it"
What am i doing wrong here?

By the way, I am using both programs on the same computer
-
- VIP Livecode Opensource Backer
- Posts: 10045
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Making an ultra-simple Livecode server and client
Is the port in use by another program?
You may need to check the value of "the result" after the connection attempt to see if you can get more info about what's going on.
You may need to check the value of "the result" after the connection attempt to see if you can get more info about what's going on.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Making an ultra-simple Livecode server and client
I think I solved that, the problem actually lies in the server end,
You do not get the sent pop-up, that explains why the client could not read it, it was never sent!
So my real question should be what am I doing wrong on the server end?
I do not know if the port is in use, I tried another one and still no luck
Code: Select all
write "hello" to socket connected
answer "Sent"
So my real question should be what am I doing wrong on the server end?
I do not know if the port is in use, I tried another one and still no luck
-
- VIP Livecode Opensource Backer
- Posts: 10045
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Making an ultra-simple Livecode server and client
Sending data from the server is the third thing that happens. First the server sets itself up on the port, then the client connects to it. It may be worthwhile checking the earlier two events.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- Livecode Opensource Backer
- Posts: 447
- Joined: Mon Jan 23, 2012 12:46 pm
Re: Making an ultra-simple Livecode server and client
Maybe this example will give you some insight:
https://sites.google.com/a/pgcps.org/li ... uter-games
Good Luck!
https://sites.google.com/a/pgcps.org/li ... uter-games
Good Luck!
