Profile picture
Robᵉʳᵗ Graham 🤔 @ErrataRob
, 6 tweets, 2 min read Read on Twitter
So I've written a small sample web server, as one does.

This one is written in Lua on top of a weird integration of Lua-in-C using coroutines.
github.com/robertdavidgra…
github.com/robertdavidgra…
At some point I'm going to stop playing around and add Lua scripting into masscan. Lua is a language (like JavaScript, Ruby, Python, etc.) that's easy to integrate into things. It's integrated into important cybersec tools like nginx, Wireshark, Snort, nmap, and World of Warcraft
Why it's cool for masscan, nginx, and nmap is that it supports massive numbers (millions?) of user-mode threads called "coroutines" that have only about 1k of overhead per thread.
In the above sample program, when the thread does a socket:receiveline(), it actually exits the script, returning control to C, which then has a dispatch loop waiting for data to arrive, to then resume the script with the results.
So it's not an example "how best to write a web server", but "how to do things a certain way", using the extremely well-known problem of a web server to demonstrate.
Anyway, the linked project has a bunch of minimal programs for demonstrating integrating Lua into a C program, each focused on a different aspect of that. I don't know if it's useful to anybody else:
github.com/robertdavidgra…
Missing some Tweet in this thread?
You can try to force a refresh.

Like this thread? Get email updates or save it to PDF!

Subscribe to Robᵉʳᵗ Graham 🤔
Profile picture

Get real-time email alerts when new unrolls are available from this author!

This content may be removed anytime!

Twitter may remove this content at anytime, convert it as a PDF, save and print for later use!

Try unrolling a thread yourself!

how to unroll video

1) Follow Thread Reader App on Twitter so you can easily mention us!

2) Go to a Twitter thread (series of Tweets by the same owner) and mention us with a keyword "unroll" @threadreaderapp unroll

You can practice here first or read more on our help page!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just three indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member and get exclusive features!

Premium member ($3.00/month or $30.00/year)

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!