DEV Community

Discussion on: Minimal API in c

Collapse
 
pbouillon profile image
Pierre Bouillon

Thank you so much !

I will build my researches around this, thank you for your time !!

Collapse
 
phlash profile image
Phil Ashby

You're welcome - there are a few things I would say about writing network services in C, and particularly on unix-like systems:

  • memory management will be a PITA as soon as you want to do anything complex (there is already a 1024 byte buffer in this example!)
  • look at the inetd way of doing this - it manages networking and sub programs provide protocol handling via stdio, use the pipes Luke :)
  • have a go at turning the example into an HTTP/0.9 server (no request headers, just the request line to parse), if you feel brave look at adding handler threads with pthreads... then never expose to the 'net as pretty much all C network code has vulnerabilities, especially mine!

Have fun!