• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
SO_REUSEADDR
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: SO_REUSEADDR
      • From: "Justin C. Walker" <email@hidden>
  • Prev by Date: Re: Unscheduling CFReadStream from run loop
  • Next by Date: Re: SO_REUSEADDR
  • Previous by thread: RE: Unscheduling CFReadStream from run loop
  • Next by thread: Re: SO_REUSEADDR
  • Index(es):
    • Date
    • Thread