我只想尝试一些lua客户端和java服务器,我已经看到了这个问题:
How to get the TCP reply in lua?:
服务器:
import java.net.*;
import java.io.*;
public class server {
public static void main(String args[]) throws Exception {
ServerSocket server = null;
Socket client = null;
PrintStream out = null;
BufferedReader buf = null;
server = new ServerSocket(8000);
client = server.accept();
buf = new BufferedReader(
new InputStreamReader(client
.getInputStream()));
out = new PrintStream(
client.getOutputStream());
String str = buf.readLine();
out.println("Echo:"+str);
System.out.println("HELLO"+str);
out.close();
client.close();
}
};
客户端:
local socket = require("socket")
local host = "127.0.0.1"
local port = 8000
local sock = assert(socket.connect(host, port))
sock:settimeout(10)
print("Press enter after input something:")
local input, recvt, sendt, status
input = io.read()
if #input > 0 then
assert(sock:send(input .. "\n"))
end
local response, receive_status = sock:receive()
print(response)
我无法看到如何设置lua api,library / lua的路径 - 我该如何设置它?
答案 0 :(得分:0)
在Lua VM中,它分别是package.path
和package.cpath
,分别用于Lua软件包和C API软件包。这些最初设置为LUA_PATH
和LUA_CPATH
个环境变量。路径用分号(;
)