Skip to content

nikouu/mGBA-lua-Socket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

The end goal is to send a message to mGBA via sockets.

How to run

  1. See my mGBA-lua-HelloWorld repository for basic setup instructions.
  2. Ensure you're running a ROM in mGBA.
  3. Load socketserver.lua
  4. Open SocketClient.sln for the manual C# socket client.
  5. Run/debug SocketClient

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 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).

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:

  • 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.

About

Small project to understand how the mGBA implementation of lua sockets works.

Topics

Resources

License

Stars

Watchers

Forks