I'm an absolute Newbie here. I done even know if the following is possible..
I currently control an application by a command line interface having opened a Telnet connection. Once opened and connected I then communicate by typing some commands such as "scene</net_remote_23>.activate" or scene.</next>". After each command I press "Return" and in the telnet window I get a text response after each command.
What I need to do is to open the equivalent in Runrev.
I thought maybe a button with a script to login
on mouseUp
open socket to "192.168.5.39:19201"
end mouseUp
and other buttons with pre-assigned "mouse up" instructions.
on mouseUp
send "scene</net_remote_23>.activate"
end mouseUp
What I cant find is how to send the text in runrev as mentioned above, or how to get the reply back from the receiving machine.
I'm sure its quite simple, and I just need an example of the above, and I can work the rest out.
Regards
Peter
TCP/IP Socket Telnet
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: TCP/IP Socket Telnet
HI Peter,
You really, really, really should look up the word "send" in the RunRev dictionary. That will tell you that your script is definitely wrong. Additionally, you will want to search for the word "socket" and read all the information you can find about it.
Writing a telnet client is slightly more difficult than a server. You need to figure out what commands your telnet server exactly expects and whether you need to escape particular characters, whether you need to send just a linefeed or a carriage return or both after each command et cetera.
Basically, you can just open a socket to a telnet server. Keep the socket open during the telnet session. Each time when you write to the socket, read from it with a message.
For example, a field can contain the following script:
It isn't exactly what you're looking for, but you can find a complete script for a telnet server on my blog at http://blog.schonewille.tk/. At the time of writing, it is the second article.
Best,
Mark
You really, really, really should look up the word "send" in the RunRev dictionary. That will tell you that your script is definitely wrong. Additionally, you will want to search for the word "socket" and read all the information you can find about it.
Writing a telnet client is slightly more difficult than a server. You need to figure out what commands your telnet server exactly expects and whether you need to escape particular characters, whether you need to send just a linefeed or a carriage return or both after each command et cetera.
Basically, you can just open a socket to a telnet server. Keep the socket open during the telnet session. Each time when you write to the socket, read from it with a message.
For example, a field can contain the following script:
Code: Select all
on returnInField
sendMessage the text of me
end returnInField
global gSomeSocket
on sendMessage theData
write theData & cr to socket gSomeSocket
read from socket gSomeSocket until cr with message "receivedMessage"
end sendMessage
on receivedMessage theSock,theMsg
-- do something with theMsg here
-- e.g. put it into a field for user interaction
put theSock & cr after field "Console"
end receivedMessage
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: TCP/IP Socket Telnet
Hi Mark,
Thanks for the insight and code snippets. With reading through the manual I put the following together to prove that I can communicate with my software application and eventually found it needs a CRLF to make it work. It works and I can control my app!
#Connect button
on mouseUp
open socket to "192.168.5.39:19201"
end mouseUp
------
#Disconnect button
on mouseUp
close socket "192.168.5.39:19201"
end mouseUp
-------
#Send button
on mouseUp
write "s.</Next>"& crlf to socket "192.168.5.39:19201"
end mouseUp
-------
I know its not pretty and there is no error checking, or is no way the correct way to do things!
Thats my next step, also reading any messages sent back to this client. That I can work on.
My problem now is that although it works inside RunRev programming environment, If I make it into a Web application (Only Option as Running RevMedia) it doesnt work. Is there a simple reason for that? or do I need to add something else? Ive only tried it on the same computer (Apple Mac).
Regards
Peter
Thanks for the insight and code snippets. With reading through the manual I put the following together to prove that I can communicate with my software application and eventually found it needs a CRLF to make it work. It works and I can control my app!
#Connect button
on mouseUp
open socket to "192.168.5.39:19201"
end mouseUp
------
#Disconnect button
on mouseUp
close socket "192.168.5.39:19201"
end mouseUp
-------
#Send button
on mouseUp
write "s.</Next>"& crlf to socket "192.168.5.39:19201"
end mouseUp
-------
I know its not pretty and there is no error checking, or is no way the correct way to do things!
Thats my next step, also reading any messages sent back to this client. That I can work on.
My problem now is that although it works inside RunRev programming environment, If I make it into a Web application (Only Option as Running RevMedia) it doesnt work. Is there a simple reason for that? or do I need to add something else? Ive only tried it on the same computer (Apple Mac).
Regards
Peter
Re: TCP/IP Socket Telnet
Dear Peter,
If you look at the Web pane of the Standalone Application Settings, you will see a section called Security Settings. If you change these settings, then the user of your software will be asked for permission when the revlet loads. Probably, you need to turn on the Network option. If that doesn't work, try the other options too.
Best,
Mark
If you look at the Web pane of the Standalone Application Settings, you will see a section called Security Settings. If you change these settings, then the user of your software will be asked for permission when the revlet loads. Probably, you need to turn on the Network option. If that doesn't work, try the other options too.
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode