int getsockname(int sockfd, struct sockaddr *addr, socklen_t *addrlen); getsockname() returns the current address to which the socket sockfd is bound,in the buffer pointed to by addr. The addrlen argument should be initialized to indicate the amount…