Bloxxy Posted August 19, 2023 Share Posted August 19, 2023 Hey, so I am trying to do TCP Requests. A older post here mentioned including "socket" or "luasocket", but it seems like these modules are not found. This is some code I tried: local socket = require("socket") -- Define the server's IP address and port local serverIP = "192.168.100.15" local serverPort = 16427 -- Create a TCP socket local client = socket.tcp() -- Connect to the server client:connect(serverIP, serverPort) -- Send data to the server local messageToSend = "Hello, server!" client:send(messageToSend) -- Receive data from the server local receivedData, err = client:receive() if receivedData then print("Received data from server: " .. receivedData) else print("Error while receiving data: " .. err) end -- Close the connection client:close() Link to comment Share on other sites More sharing options...
MAARS Posted August 20, 2023 Share Posted August 20, 2023 C Module like luasocket are not available on game guardian see the API for available method Link to comment Share on other sites More sharing options...
Bloxxy Posted August 20, 2023 Author Share Posted August 20, 2023 There is no TCP api here, only some HTTP methods which are way slower than TCP and I cannot use it reliably in my project Link to comment Share on other sites More sharing options...
Count_Nosferatu Posted August 20, 2023 Share Posted August 20, 2023 (edited) Why are you not using command gg.makeRequest ? Edited August 20, 2023 by Count_Nosferatu Link to comment Share on other sites More sharing options...
kiynox Posted August 20, 2023 Share Posted August 20, 2023 [ @Bloxxy ] --- Lua that's bundled inside Game Guardian cannot use external module and even some Lua internal modules. But, Game Guardian do support HTTP bequest, so your server needs to also support HTTP/HTTPS protocol, otherwise there's nothing you can do about it. Yes, even plain TCP aren't do-able. --- See request documentation: gg.makeRequest Link to comment Share on other sites More sharing options...
Bloxxy Posted August 21, 2023 Author Share Posted August 21, 2023 How cannot Game Guardian use external modules? I can use require for Lua modules just fine, not C though. Http is too slow in my case, I need to deliver 500 bytes and HTTP adds a 200 bytes overhead. I am running the server on a computer above the VM, but technically that still gets into the network, getting a 2ms additional delay, and HTTP makes a new socket for every request making it way too slow for my needs. Why are simple features that are needed like TCP excluded? Link to comment Share on other sites More sharing options...
kiynox Posted August 21, 2023 Share Posted August 21, 2023 [ @Bloxxy ] --- Quote I can use require for Lua modules just fine Yes, I mean it as partially. --- Quote HTTP makes a new socket for every request making it way too slow for my needs You can re-use existing socket by using HTTP Pipelining: See GET / HTTP/1.1\r\n Host: blah.com\r\n \r\n GET / HTTP/1.1\r\n Host: blah.com\r\n \r\n --- Quote I need to deliver 500 bytes and HTTP adds a 200 bytes overhead 200 bytes for headers, etc; is not a lot and still reasonable. --- Link to comment Share on other sites More sharing options...
Bloxxy Posted August 23, 2023 Author Share Posted August 23, 2023 On 8/21/2023 at 7:27 PM, Xaviesz said: [ @Bloxxy ] --- Yes, I mean it as partially. --- You can re-use existing socket by using HTTP Pipelining: See GET / HTTP/1.1\r\n Host: blah.com\r\n \r\n GET / HTTP/1.1\r\n Host: blah.com\r\n \r\n --- 200 bytes for headers, etc; is not a lot and still reasonable. --- HTTP standard on the exact same page you posted says that you should not use pipelining on post requests, and even if that's possible it would make a 4x delay from 5ms to 20ms if I combine 4 posts. And 200 is a lot, it's almost 45% useless data that doesn't help me and just makes the response harder to parse Link to comment Share on other sites More sharing options...
kiynox Posted August 23, 2023 Share Posted August 23, 2023 [ @Bloxxy ] --- Quote even if that's possible it would make a 4x delay from 5ms to 20ms Welp, I can only suggest you some workaround using HTTP. I don't even know How Game Guardian lua's handle HTTP/2 or HTTP/3. You might need to use HTTP/2 Multiplexing or take care of HTTP/3 which use UDP (Quic) which make it more reasonably faster if you care about connection speed. Connection speed involve many factor and not just at protocol perspective (using CDN for example). --- Second suggestion is to get your-self multipart body, this will avoids your sended data to be encoded first (\0x88\xblah), less hassle into connection speed. --- Third, switching protocol to Websocket from HTTP/1. I don't know how Game Guardian handles this but you can switch HTTP/1 to Websocket using this Headers: Quote Upgrade: websocket\r\nSec-Websocket-Version: 13\r\n\r\n --- That's pretty much wraps any ideas I would have. It is very limited, you might find yourself using another way instead of doing it inside Game Guardian. Link to comment Share on other sites More sharing options...
Bloxxy Posted August 24, 2023 Author Share Posted August 24, 2023 9 hours ago, Xaviesz said: [ @Bloxxy ] --- Welp, I can only suggest you some workaround using HTTP. I don't even know How Game Guardian lua's handle HTTP/2 or HTTP/3. You might need to use HTTP/2 Multiplexing or take care of HTTP/3 which use UDP (Quic) which make it more reasonably faster if you care about connection speed. Connection speed involve many factor and not just at protocol perspective (using CDN for example). --- Second suggestion is to get your-self multipart body, this will avoids your sended data to be encoded first (\0x88\xblah), less hassle into connection speed. --- Third, switching protocol to Websocket from HTTP/1. I don't know how Game Guardian handles this but you can switch HTTP/1 to Websocket using this Headers: --- That's pretty much wraps any ideas I would have. It is very limited, you might find yourself using another way instead of doing it inside Game Guardian. I would prefer not using UDP, since I need all the packets to arrive (and in the order sent). Switching to Websocket mode is useless, since Game Guardian closes the TCP remote instantly after sending the message, so it's like making a Websocket but not sending any data and closing it instantly. I wonder why this popular modding application misses the most important feature any application should have Link to comment Share on other sites More sharing options...
kiynox Posted August 25, 2023 Share Posted August 25, 2023 (edited) [ @Bloxxy ] --- Quote I would prefer not using UDP, since I need all the packets to arrive (and in the order sent). Quic is build on top of UDP but it doesn't make it a Lossless protocol. Even though the UDP itself is unreliable and lossless but Quic is different, it is reliable, accurate and sure is fast. It is behaving like TCP but on top of UDP. There's a reason Google implemented this. --- Quote I wonder why this popular modding application misses the most important feature any application should have Game Guardian is not a packet oriented application, it's only focusing on what memory debugging should have. I believe gg.makeRequest() is only added just for the shake of Lua extension support. --- Edited August 25, 2023 by Xaviesz 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now