Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nikouu/mgba-lua-socket
Small project to understand how the mGBA implementation of lua sockets works.
https://github.com/nikouu/mgba-lua-socket
csharp dotnet lua lua-script mgba socket
Last synced: 11 days ago
JSON representation
Small project to understand how the mGBA implementation of lua sockets works.
- Host: GitHub
- URL: https://github.com/nikouu/mgba-lua-socket
- Owner: nikouu
- License: mit
- Created: 2023-10-05T00:27:41.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-06T04:41:21.000Z (about 1 year ago)
- Last Synced: 2024-12-22T19:38:25.771Z (11 days ago)
- Topics: csharp, dotnet, lua, lua-script, mgba, socket
- Language: Lua
- Homepage:
- Size: 135 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mGBA lua Socket
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](https://github.com/mgba-emu/mgba/tree/master/res/scripts).The end goal is to send a message to mGBA via sockets.
## How to run
0. See my [mGBA-lua-HelloWorld repository](https://github.com/nikouu/mGBA-lua-HelloWorld) for basic setup instructions.
1. Ensure you're running a ROM in mGBA.
2. Load `socketserver.lua`
3. Open `SocketClient.sln` for the manual C# socket client.
4. Run/debug `SocketClient`
![](images/MessageReceivedDotnet.jpg)## Protocol issues?
- 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 pointsSee below for comparisons between the .NET client in the repo and Postman.
| Client | Result |
| ----------------- | ----------------------------------------------- |
| Custom .NET | ![](images/MessageReceivedDotnet.jpg) |
| Postman HTTP | ![](images/MessageReceivedPostmanHttp.jpg) |
| Postman Websocket | ![](images/MessageReceivedPostmanWebsocket.jpg) |It seems the [socket error](https://mgba.io/docs/scripting.html#constant-SOCKERR) 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*).
## Notes
- Even after manually adding in a response via `sock:send("<|ACK|>")` seems to also not work and gives a `Error: Parse Error: Expected HTTP/` error:
![](images/PostmanError.jpg)
- 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.