In the preceding post I discussed with you the means to create sockets and to form addresses for them. This chapter will expand upon this, enabling you to understand how bind(2) works and
how to apply it correctly. In this post, you will learn
- How the bind(2) function call assigns an address to a socket
- How to obtain the local socket address from a socket that already has an existing address
- How to obtain the peer socket address
- How bind(2) can choose the network interface that is used for communication
The post 2 of this series, Domains and Address Families," covered addresses in detail. This background will make easy for you to follow. Having mastered the bind function, you will be able to
put sockets to work easy in your code.