what is the issue/difference between ip 127.0.0.1(localhost) and 0.0.0.0?
submitted 2 years ago by [deleted] from (self.programming)
i am writing a custom web server in C language and just thought that i should cover this issue before proceeding any further.
[–]Antarchomachus 5 insightful - 1 fun5 insightful - 0 fun6 insightful - 0 fun6 insightful - 1 fun - 2 years ago* (4 children)
Hey wonderwoman. 127.0.0.1 is the loopback route. 0.0.0.0 is a default that will technically listen on all addresses. You will see people use the 0.0.0.0 as the localhost in many code samples because it will listen at 127.0.0.1 in addition to the other addresses
On another note, I love C, but not sure this is the best choice for a web server unless this a purely academic exercise. C# is used in the microsoft universe, but i rarely see pure C used this way
[–][deleted] 2 insightful - 1 fun2 insightful - 0 fun3 insightful - 0 fun3 insightful - 1 fun - 2 years ago (1 child)
yeah, but i am so fluent in c... i understand that the new kids have moved on to c sharp, but i just dont know it as well.
and last time i tried to download a microsoft ide, it was such a bloat nightmare that i dont think i want to do that again..
is it me or is the "dot net" thing a bloat nightmare? i am not even sure what it does..
[–]Antarchomachus 2 insightful - 1 fun2 insightful - 0 fun3 insightful - 0 fun3 insightful - 1 fun - 2 years ago* (0 children)
Ok then this is fine for writing a socket server. You will actually get a great idea of how this works behind the scenes, because C forces you to do everything manually. My first socket server was in Python, which gets interpreted to C, but the interface hid a lot of the complexities.
I am not a huge fan of the dot net environment, but C# in general is pretty easy to get used to if you know C already.
so if i write my sockets server and have it bind to 0.0.0.0 it will catch all traffic? is it possible that i can bind a server that will catch ALL traffic on my computer to all ports?
is that a stupid question?
[–]Antarchomachus 2 insightful - 1 fun2 insightful - 0 fun3 insightful - 0 fun3 insightful - 1 fun - 2 years ago (0 children)
It will catch traffic coming to any IP address accessible from your machine, including the loopback interface. I misused the word 'port'. 0.0.0.0 listens to all 'IP addresses', the actual port is a different matter
[–]bopomofodojo 2 insightful - 1 fun2 insightful - 0 fun3 insightful - 0 fun3 insightful - 1 fun - 2 years ago (1 child)
127.0.0.1 (and, properly, the whole 127.0.0.0/8 CIDR range) is for loopback addresses. These addresses are not routeable and are always used for local connections to the same host.
0.0.0.0 (technically, 0.0.0.0/0) is a wildcard address. How it behaves is system-specific, but on most UNIX-like systems it means "bind on all possible IPs on this host". It isn't actually a valid address, simply used as a placeholder to represent the "bind on everything" notion.
Without going into the pros and cons of writing a custom webserver in C (mostly cons), generally you'd want to support both since they both do different things and different admins will have different uses for them.
[–][deleted] 2 insightful - 1 fun2 insightful - 0 fun3 insightful - 0 fun3 insightful - 1 fun - 2 years ago (0 children)
Thank you very much.
[–]package 1 insightful - 1 fun1 insightful - 0 fun2 insightful - 0 fun2 insightful - 1 fun - 2 years ago (0 children)
i am writing a custom web server in C language
hmmmmmmmmmmmmmmmmmmmmm https://saidit.net/s/whatever/comments/8dht/introducing_websockets_bringing_sockets_to_the/
use the following search parameters to narrow your results:
e.g. sub:pics site:imgur.com dog
sub:pics site:imgur.com dog
advanced search: by author, sub...
~3 users here now
Links:
[–]Antarchomachus 5 insightful - 1 fun5 insightful - 0 fun6 insightful - 0 fun6 insightful - 1 fun - (4 children)
[–][deleted] 2 insightful - 1 fun2 insightful - 0 fun3 insightful - 0 fun3 insightful - 1 fun - (1 child)
[–]Antarchomachus 2 insightful - 1 fun2 insightful - 0 fun3 insightful - 0 fun3 insightful - 1 fun - (0 children)
[–][deleted] 2 insightful - 1 fun2 insightful - 0 fun3 insightful - 0 fun3 insightful - 1 fun - (1 child)
[–]Antarchomachus 2 insightful - 1 fun2 insightful - 0 fun3 insightful - 0 fun3 insightful - 1 fun - (0 children)
[–]bopomofodojo 2 insightful - 1 fun2 insightful - 0 fun3 insightful - 0 fun3 insightful - 1 fun - (1 child)
[–][deleted] 2 insightful - 1 fun2 insightful - 0 fun3 insightful - 0 fun3 insightful - 1 fun - (0 children)
[–]package 1 insightful - 1 fun1 insightful - 0 fun2 insightful - 0 fun2 insightful - 1 fun - (0 children)