Re: Telnet help

new topic     » goto parent     » topic index » view thread      » older message » newer message
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 thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu