When I programmed in python, I believe I interfaced with the transport layer using sockets. If python was programmed by humans, they must have used an interface that was “lower” than sockets, to provide us with the interface to sockets. I assume firewalls, also programmed by humans, use interfaces of lower layers in the same manner, so is there a way to access such lower layers, in terms of programming?
7
A language uses system calls to communicate with the lower layer
In an interpreted language it means that the script calls a “built in” function and then code outside the interpreter gets called (which then makes its own system calls).
In a compiled language the code signals a software interrupt which signals the OS that it needs something from outside using a predefined protocol.
The C standard is mostly convenience functions and wrappers around these system calls so the programmer doesn’t need to remember how to signal each OS.
To give some detail, here is Python’s implementation of the socket()
call. That is, the following code is called when you do x=socket.socket()
in Python, which initializes a _socketobject
object for you. It shows that in CPython, eventually it calls the good old C socket()
function.
http://hg.python.org/cpython/file/57130574d1e8/Modules/socketmodule.c#l3995