[ prog / sol / mona ]

prog


Network Programming

2 2018-11-24 05:02

It depends what level you're working on. Writing a simple HTTP API is easy. With most micro-frameworks, you just write callbacks for each URL suffix and HTTP method pairs you support. With others, you just write a callback for when somebody sends a HTTP request. The callback returns the HTTP response you send back.

If you're doing stuff at the socket level, you're going to have to write a parser, and that's a huge pain to do correctly with all but the simplest formats, since end of message doesn't necessarily mean end of packet and you could get a disconnect before the full message is sent. You can always cop out and assume every packet will contain a full message, load the contents into a buffer, and attempt to parse it. That'll mostly work as long as the messages are short. Anything less than a kilobyte at a time should be fine most of the time.

12


VIP:

do not edit these