Tema: Servidor C++
Ver Mensaje Individual
  #6 (permalink)  
Antiguo 21/07/2011, 10:27
sam90
 
Fecha de Ingreso: abril-2010
Ubicación: Rosario
Mensajes: 1.850
Antigüedad: 14 años, 1 mes
Puntos: 228
Respuesta: Servidor C++

Mira lo que encontre en esta pagina:
http://beej.us/guide/bgnet/output/ht...gnet.html#bind

Sometimes, you might notice, you try to rerun a server and bind() fails, claiming "Address already in use." What does that mean? Well, a little bit of a socket that was connected is still hanging around in the kernel, and it's hogging the port. You can either wait for it to clear (a minute or so), or add code to your program allowing it to reuse the port, like this:
Código C++:
Ver original
  1. int yes=1;
  2. //char yes='1'; // Solaris people use this
  3.  
  4. // lose the pesky "Address already in use" error message
  5. if (setsockopt(listener,SOL_SOCKET,SO_REUSEADDR,&yes,sizeof(int)) == -1) {
  6.     perror("setsockopt");
  7.     exit(1);
  8. }