cmidi
cmidi

Reputation: 2010

Why TCP accepted socket does not need bind(int, __CONST_SOCKADDR_ARG, socklen_t)

Is the child socket created after

int accept(__fd, __SOCKADDR_ARG __addr, socklen_t *__restrict __addr_len)  

bound to a local address, if not why?

Upvotes: 0

Views: 229

Answers (1)

Remy Lebeau
Remy Lebeau

Reputation: 597016

Yes, it is bound to a local IP/port. It is bound to the specific local IP that accepted the connection request (especially if the listening socket is bound to multiple local IPs via a wildcard IP, like INADDR_ANY), and to the same local port that the listening socket is bound to.

Upvotes: 2

Related Questions