1. Telnet help

I need to use Euphoria to send a simple string via telnet protocol. Using the telnet program works:

irv@Mint18 ~ $ telnet localhost 5401 
Trying 127.0.0.1... 
Connected to localhost. 
Escape character is '^]'. 
 
/> set /autopilot/settings/heading-bug-deg 180 

But, of course, I need to send the strings from Euphoria, not by typing them into an x-term. I have tried to use the std/sockets library (Eu 4.1) with no success, because I don't understand it at all. Can someone help with a simple example?

new topic     » topic index » view message » categorize

2. Re: Telnet help

Michael Raley wrote an Eu lib in 2000, it's in the archives.

I used telnet to get my email way back on win95, the isp/telco accused me of trying to hack their system. Be careful.

new topic     » goto parent     » topic index » view message » categorize

3. Re: Telnet help

katsmeow said...

Michael Raley wrote an Eu lib in 2000, it's in the archives.

I used telnet to get my email way back on win95, the isp/telco accused me of trying to hack their system. Be careful.

Thanks.

This will be all on my local network. Should be ok.

Unfortunately, that library is awfully complex, and it's for Windows, so even if I could figure it out, it won't work in my application.

new topic     » goto parent     » topic index » view message » categorize

4. Re: Telnet help

irv said...

I need to use Euphoria to send a simple string via telnet protocol. Using the telnet program works:

irv@Mint18 ~ $ telnet localhost 5401 
Trying 127.0.0.1... 
Connected to localhost. 
Escape character is '^]'. 
 
/> set /autopilot/settings/heading-bug-deg 180 

But, of course, I need to send the strings from Euphoria, not by typing them into an x-term. I have tried to use the std/sockets library (Eu 4.1) with no success, because I don't understand it at all. Can someone help with a simple example?

I don't understand. Do you need to set up a pty and do VT102 emulation for a user over the console or something? Why wouldn't this work?

        sockets:socket sock = sockets:create(sockets:AF_INET, sockets:SOCK_STREAM, 0) 
        if sockets:connect(sock, "127.0.0.1:5401") != sockets:OK then 
	-- handle error and abort? 
	end if 
        sequence datum = receive(sock, 0) 
	if match("/> ", datum) then 
        _ = sockets:send(sock, "set /autopilot/settings/heading-bug-deg 180\r\n", 0) 
	end if 
        _ = sockets:close(sock) 
new topic     » goto parent     » topic index » view message » categorize

5. Re: Telnet help

Thanks! Your code works (with a minor modification). I must have tried every possible way to use sockets except the right one!

include std/socket.e 
include std/console.e 
  
integer deg = 90 
  
object msg = sprintf("set /autopilot/settings/heading-bug-deg %d\r\n",deg) 
        
sockets:socket sock = sockets:create(sockets:AF_INET, sockets:SOCK_STREAM, 0)  
         
if sockets:connect(sock, "127.0.0.1:5401") = 0 then  
 
    if sockets:send(sock,msg, 0) != length(msg) then display("ERROR\n")  
    else display(sockets:receive(sock,0)) -- view confirmation msg; 
    end if 
 
sockets:close(sock)  
 
end if 
new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu