how to access system files such as network libraries?
Apple has published quite a lot of source code


Open Source: Source code for a lot of frameworks and commands
Open Source Development Resources


PS: Any detailled discussion about the code (or even where to find which functionality) is off topic on AskDifferent and should be discussed on StackOverflow.