Another possibly stupid question (I really have no idea of this stuff :)): How does the socket/fd stay valid if the sock variable is local here?