SO_REUSEADDR
SO_REUSEADDR
- Subject: SO_REUSEADDR
- From: Troy Dawson <email@hidden>
- Date: Wed, 8 Mar 2006 18:58:39 -0800
In creating a UDP listening socket:
int main(int argc, char *argv[])
{
int sock = socket(AF_INET, SOCK_DGRAM, 0);
if (sock < 0)
{
perror("socket");
exit(1);
}
struct sockaddr_in server;
memset(&server, 0, sizeof(server));
server.sin_family = AF_INET;
server.sin_addr.s_addr = htonl(INADDR_ANY);
server.sin_port = htons(12355);
int rc = 1;
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &rc, sizeof(rc));
if (bind(sock, (struct sockaddr *) &server, sizeof(server)) < 0)
{
perror("bind");
exit(1);
}
is giving me this error:
"bind: Address already in use"
when I run a second instance of the server...
What am I doing wrong ??? TIA.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden