home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!portal!lll-winken!parc!decwrl!elroy.jpl.nasa.gov!swrinde!cs.utexas.edu!ut-emx!ibmchs!auschs!awdalpha.austin.ibm.com!awdprime.austin.ibm.com!ravikm
- From: ravikm@austin.ibm.com (Ravi K Mandava)
- Newsgroups: comp.unix.programmer
- Subject: Re: Socket Programming Help
- Message-ID: <1992Nov5.160451.5092@awdprime.austin.ibm.com>
- Date: 5 Nov 92 16:04:51 GMT
- References: <1992Nov4.143004.22495@nuscc.nus.sg>
- Sender: news@awdprime.austin.ibm.com (USENET News)
- Reply-To: ravikm@piobe.austin.ibm.com
- Organization: IBM Austin
- Lines: 24
- Originator: ravikm@piobe.austin.ibm.com
-
-
- In article <1992Nov4.143004.22495@nuscc.nus.sg>, scstech@solomon.technet.sg (Kenneth Soh) writes:
- > I keep having "Address already in use" (errno 48) problem
- > everytime I restart the deamon with the same port number -
- > the bind() function returns error. The same port number
- > seems to be "released" and re-usable after say, half an
- > hour.
-
- Before bind(), set your socket to be reused by calling setsockopt().
- Ex: int on = 1;
- ... setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, (char *)&on,
- (int)(sizeof on));
-
- > sin.sin_addr.s_addr = INADDR_ANY;
- > sin.sin_port = atoi(argv[1]); <-- just a port number
-
- Also, if these are not already in network format, use
- sin.sin_addr.s_addr = htonl((ulong_t)INADDR_ANY);
- sin.sin_port = htons((ushort_t)atoi(*argv));
-
- --
- *******************************************************************************
- Ravi K Mandava email: piobe!ravikm@ibmpa.awdpa.ibm.com
- *******************************************************************************
-