Lua Netzwerk Connect: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
(Die Seite wurde neu angelegt: „<pre> local socket = require("socket") local host = "192.168.34.1" local port = "22" local tcp = assert(socket.tcp()) tcp:connect(host, port); tcp:send("SSH-2…“) |
|||
| Zeile 1: | Zeile 1: | ||
| − | < | + | <syntaxhighlight lang="lua"> |
| − | + | socket = require("socket") | |
| − | + | tcp = assert(socket.tcp()) | |
| − | + | host = "127.0.0.1" | |
| − | + | port = "22" | |
tcp:connect(host, port); | tcp:connect(host, port); | ||
| − | tcp:send("SSH-2.0- | + | s, status, partial = tcp:receive() |
| − | + | print(s or partial) | |
| − | + | status = tcp:send("SSH-2.0-OpenSSH_9.0\n"); | |
| − | + | print(status) | |
| − | + | --s, status, partial = tcp:receive(1024) | |
| − | + | --s, status, partial = tcp:receive('*a') | |
| − | + | s, status, partial = tcp:receive(1036) | |
| − | + | print(s or partial) | |
| − | |||
tcp:close() | tcp:close() | ||
| − | </ | + | </syntaxhighlight> |
Version vom 6. März 2023, 13:51 Uhr
socket = require("socket")
tcp = assert(socket.tcp())
host = "127.0.0.1"
port = "22"
tcp:connect(host, port);
s, status, partial = tcp:receive()
print(s or partial)
status = tcp:send("SSH-2.0-OpenSSH_9.0\n");
print(status)
--s, status, partial = tcp:receive(1024)
--s, status, partial = tcp:receive('*a')
s, status, partial = tcp:receive(1036)
print(s or partial)
tcp:close()