With the following snapshot of C code, I understand that, the address that bind()
call binds to listfd
, is the logical address of the local machine wh
I agree the Coursera material is probably wrong or at least misleading for introduction level learning about network programming.
However, I can not suppress a pedantic comment. It is possible (on Linux) to bind to a non-local IP address. Please see option IP_TRANSPARENT at http://man7.org/linux/man-pages/man7/ip.7.html. This probably has very little to do with the issue at hand, though. Also i appreciate the question is tagged bsd.
More on the point, bind()
does not have anything to do with listening. It simply associates the fd with an address. It is the listen()
call that enables "listening". It is possible to bind()
a socket used for outgoing connections.