This forum is now read-only. Please use our new forums at

519 points
Submitted by
over 3 years ago

Question 17 Inquiry about .close()

Why is it that we don't have to invoke .close() on our opened URL, like we normally should with files that we open through command prompt or something.

We can just print and go along with our lives?

0 votes


To put it simply, there is no "opened" url.

What's actually happening is that every time you make a request, information is sent to that url, and then information is send back. It doesn't constantly stay "open", instead it "opens" when information needs to be sent or received.

However, in python, there is a way to "bind" what is called a socket(basically the same thing as a XMLHttpRequest() in JS) to a connection, as the following code demonstrates:

import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(("", 8000))

The socket, s, will remain binded to the connection until it is aborted, or closed.

848 points
Submitted by
almost 3 years ago