+ sin.sin_addr.s_addr = INADDR_ANY;
+ /*
+ * If a local hostname is given (-n option to statd), bind to the address
+ * specified. This is required to support clients that ignore the mon_name in
+ * the statd protocol but use the source address from the request packet.
+ */
+ if (MY_NAME) {
+ struct hostent *hp = gethostbyname(MY_NAME);
+ if (hp)
+ sin.sin_addr = *(struct in_addr *) hp->h_addr;
+ }
+ if (port != 0) {
+ sin.sin_port = htons(port);
+ if (bind(sockfd, &sin, sizeof(sin)) == 0)
+ goto out_success;
+ note(N_CRIT, "statd: failed to bind to outgoing port, %d\n"
+ " falling back on randomly chosen port\n", port);
+ }