- struct sockaddr_in sin;
- sin.sin_port= 0;
- sin.sin_addr.s_addr= 0;
- sin.sin_addr.s_addr= INADDR_ANY;
- sin.sin_family= AF_INET;
-
- if (bind(sd, (struct sockaddr *)&sin,sizeof(struct sockaddr_in) ) != -1)
+ int optval= 1;
+ if (setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)) != -1)