Small project to understand how the mGBA implementation of lua sockets works and how to connect to it. This is pretty much entirely based off the work mGBA scripts source code folder.
The end goal is to send a message to mGBA via sockets.
- See my mGBA-lua-HelloWorld repository for basic setup instructions.
- Ensure you're running a ROM in mGBA.
- Load
socketserver.lua
- Open
SocketClient.sln
for the manual C# socket client. - Run/debug
SocketClient
- While I'm not awfully familiar with low level sockets and TCP, it seems the code from the mGBA repo doesn't respond with an ACK automatically on a recieve and as such trips up applications sending requests - such as Postman, which stays in an endless connecting state.
- I've added an ACK manually
- I've added logging points
See below for comparisons between the .NET client in the repo and Postman.
Client | Result |
---|---|
Custom .NET | |
Postman HTTP | |
Postman Websocket |
It seems the socket error that comes up is the AGAIN one. However, I'm unsure what this means, and reading the mGBA C source doesn't help me understand either. Just don't know enough low level TCP 🤷♀️ (yet).
- Even after manually adding in a response via
sock:send("<|ACK|>")
seems to also not work and gives aError: Parse Error: Expected HTTP/
error:
- I assume there would be a way to make the code protocol compliant such that Postman and other clients can easily connect. However, for the time being, I'm just happy with the C# code working.
SocketTest.lua
is leftover from the copy over from mGBA. It's not used here, but it was used for inspiration to help understand.