Wednesday | 04 DEC 2024
[ previous ]
[ next ]

D3 BASIC HTTP Server

Title:
Date: 2022-11-01
Tags:  

Another language that I've written an http server in! This was pretty straightforward, the only difficult parts were the undocumented parts of the D3 BASIC socket stuff. D3 BASIC uses the native C code and so the documentation was lacking and said to go to the host documents for information.

The biggest gotchas were that recv needed the flags parameter and it being missing, compiles fine but throws a weird error. The other big one was that the send function can't have the length calculation in it. It needs to be done before the function. This makes sense looking back as whatever the compiler is doing probably means that it isn't evaluating the BASIC code once it gets to the C function.

Overall it was a fun exercise and now with my little http server working, I have wired up D3 to serve some API endpoints and this mixed with express and ejs means that I can get some pretty tables in the browser very quickly. I'm quite happy with the state of it for now. I do have ideas about making it a full fledged web server but for now an API server is perfectly fine.

On another note, my editor is working flawlessly. I did a few mass replacing of variables as I wrote my server and everything worked. The editor was definitely a good investment.