Put the request length as a define.
Added pthread as a dependency.
Moved the request handling to it's own function.