home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / unix / programm / 5171 < prev    next >
Encoding:
Internet Message Format  |  1992-11-06  |  1.5 KB

  1. 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
  2. From: ravikm@austin.ibm.com (Ravi K Mandava)
  3. Newsgroups: comp.unix.programmer
  4. Subject: Re: Socket Programming Help
  5. Message-ID: <1992Nov5.160451.5092@awdprime.austin.ibm.com>
  6. Date: 5 Nov 92 16:04:51 GMT
  7. References: <1992Nov4.143004.22495@nuscc.nus.sg>
  8. Sender: news@awdprime.austin.ibm.com (USENET News)
  9. Reply-To: ravikm@piobe.austin.ibm.com
  10. Organization: IBM Austin
  11. Lines: 24
  12. Originator: ravikm@piobe.austin.ibm.com
  13.  
  14.  
  15. In article <1992Nov4.143004.22495@nuscc.nus.sg>, scstech@solomon.technet.sg (Kenneth Soh) writes:
  16. > I keep having "Address already in use" (errno 48) problem
  17. > everytime I restart the deamon with the same port number -
  18. > the bind() function returns error. The same port number
  19. > seems to be "released" and re-usable after say, half an
  20. > hour.
  21.  
  22.     Before bind(), set your socket to be reused by calling setsockopt().
  23.         Ex:    int on = 1;
  24.         ... setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, (char *)&on,
  25.                    (int)(sizeof on));
  26.  
  27. > sin.sin_addr.s_addr = INADDR_ANY;
  28. > sin.sin_port = atoi(argv[1]); <-- just a port number
  29.  
  30.     Also, if these are not already in network format, use
  31.     sin.sin_addr.s_addr = htonl((ulong_t)INADDR_ANY);
  32.     sin.sin_port = htons((ushort_t)atoi(*argv));
  33.  
  34. -- 
  35. *******************************************************************************
  36. Ravi K Mandava        email:    piobe!ravikm@ibmpa.awdpa.ibm.com
  37. *******************************************************************************
  38.