I searched about this a lot but I could not find anything. I haven't tried much with python sockets, just made a system where a host and a client can message each other. What I want to know is when a client is connected to a host via python socket, does it make a connection outside the program too? Like can we play any lan game after being connected via sockets for example ??
The sockets are not specific to any language; they are the logical endpoint offered by the underlying API to the userspace. You can create TCP/IP sockets in any language which supports networking.
"What I want to know is when a client is connected to a host via python socket, does it make a connection outside the program too?"
That depends on which layer you are looking at. Consider the first three layers of the TCP/IP model from the top (Application, Transport, Network).
Application Layer: All the underlying of the internet are abstracted from the Application layer. Now, if you see whether a connection is established outside your program, that purely depends on what protocol they are following. If you consider HTTP protocol, it is mostly stateless or connectionless (If cookies are ignored). But if you look at SSL, some handshakes happen, and the session state is maintained in both the client-side and server-side.
Transport Layer: The two famous protocols in this layer are TCP and UDP. With TCP before any data transfer, a TCP connection is established by performing a three-way handshake. But in the case of UDP, no such term like a connection is defined.
Internet Layer: Though the well known and most commonly used network architecture is the Internet, there are some other architectures like ATM CBR and ATM ABR. The Internet architecture falls under the category of datagram networks, meaning there is no state maintained, the link-layer switches, or routers just forward the packets. In contrast, ATM architecture falls under the category of Virtual-circuit networks. Each connection at the network layer is monitored to deliver the services. e.g., in the case of ATM CBR, the connections are monitored to deliver a constant bit rate service, and in the case of ATM ABR, the connections are monitored to deliver a minimum bit rate service.
Here I just summarized the connection setup for the first three layers, and the same things can happen with the other layers as well.
To conclude, whether the connection is established outside your programs? It depends on all these above factors, what application layer protocol you are using, what transport layer protocol you are using, and what is the underlying network architecture... etc. And you can also see a scenario where the connection establishment happens at the network layer but not in the application layer, that's where all these network abstractions come. You can blissfully ignore the underlying details!