Penguin

Differences between current version and previous revision of EADDRINUSE.

Other diffs: Previous Major Revision, Previous Author, or view the Annotated Edit History

Newer page: version 8 Last edited on Wednesday, September 6, 2006 3:03:26 pm by PerryLorier
Older page: version 7 Last edited on Wednesday, September 6, 2006 3:02:59 pm by PerryLorier Revert
@@ -22,11 +22,11 @@
 <pre> 
  unsigned int opt = 1; 
  if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt))==-1) { 
  perror("setsockopt(fd,SOL_SOCKET, SO_REUSEADDR,1)"); 
- ! exit(1); 
+ ~ exit(1); 
 
 </pre> 
  
 ---- 
  
 Another cause of this is that you have run out of spare addresses in the euphemeral port range. if you call bind(2) with a port of 0, then the kernel will choose a port out of the euphemeral port range. If there are no spare ports in this range you may get an "Address already in use" error. Under linux you can change which ports are available to be used as ephemeral ports with the <tt>net.ipv4.ip_local_port_range</tt> sysctl.