Home > front end >  What is the advantage of binding to a socket instead of an IP?
What is the advantage of binding to a socket instead of an IP?

Time:08-19

I'm following this guide to deploy a flask application to production using gunicorn

I get to this line gunicorn --bind 0.0.0.0:5000 wsgi:app and it works perfectly After that the author recommends this instead gunicorn --workers 3 --bind unix:/home/movieapp/app.sock -m 777 wsgi:app

So my (dumb) question: what is the advantage of binding to a socket instead of an IP?

Thank you for your help!

CodePudding user response:

To understand this, we need to know these terms a bit further:

IP address -> a unique address that identifies a device on the internet or a local network.

Port -> represents an endpoint or "channel" for network communications. Port numbers allow different applications on the same computer to utilize network resources without interfering with each other.

Socket -> combination of the IP address (of the station) and a port number make up a socket.

A socket can be described as a programming interface allowing a program to communicate with other programs or processes, on the internet, or locally.

Thus to conclude, an IP tells the address, a Port tells the service, while a Socket tells a particular connection (address service). Hence, they are preferred.

  • Related