# SDL\_Net: Multiserver exhausting networking re sources

**URL:** <https://discourse.libsdl.org/t/sdl-net-multiserver-exhausting-networking-re-sources/14582>\
**Category:** SDL Development\
**Created:** [June 4, 2007, 5:42pm UTC](https://discourse.libsdl.org/t/sdl-net-multiserver-exhausting-networking-re-sources/14582 "2007-06-04T17:42:06Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Miguel\_Pragier](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/m/ad7895/32.png) [@Miguel\_Pragier](https://discourse.libsdl.org/u/Miguel_Pragier)\
**Post date:** [June 4, 2007, 5:42pm UTC](https://discourse.libsdl.org/t/sdl-net-multiserver-exhausting-networking-re-sources/14582/1 "2007-06-04T17:42:06Z")

</div>

Hi, everybody.

I built a server in SDL\_Net. One server to ten clients.

This server runs on a WinXP machine nicely configured. I call this  
machine “server machine”.

Everything seems ok, but two days after start, the server machine already has  
no more networking resources. You can’t navigate, can’t run NETSTAT or even  
IPCONFIG. The O.S. message is “There’s no sufficient resources”.

The RAM memory consume is OK. Only the networking is affected.

Any of you have already passed by this kind of trouble?

Any tip? Sugestions?

---

<div class="post-metadata">

**Author:** ![Roger\_D\_Vargas](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/roger_d_vargas/32/70_2.png) [@Roger\_D\_Vargas](https://discourse.libsdl.org/u/Roger_D_Vargas)\
**Post date:** [June 4, 2007, 7:02pm UTC](https://discourse.libsdl.org/t/sdl-net-multiserver-exhausting-networking-re-sources/14582/2 "2007-06-04T19:02:30Z")

</div>

Port to linux?

miguel escribi?:\> Hi, everybody.

> I built a server in SDL\_Net. One server to ten clients.
> 
> This server runs on a WinXP machine nicely configured. I call this  
> machine “server machine”.
> 
> Everything seems ok, but two days after start, the server machine already has  
> no more networking resources. You can’t navigate, can’t run NETSTAT or even  
> IPCONFIG. The O.S. message is “There’s no sufficient resources”.
> 
> The RAM memory consume is OK. Only the networking is affected.
> 
> Any of you have already passed by this kind of trouble?
> 
> Any tip? Sugestions?
> 
> * * *
> 
> SDL mailing list  
> SDL at [lists.libsdl.org](http://lists.libsdl.org)  
> [http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org](http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)

–  
[http://dsgp.blogspot.com](http://dsgp.blogspot.com) | Linux, programaci?n, juegos  
Have no place I can be since I found Serenity  
But you can?t take the sky from me

* * *

LLama Gratis a cualquier PC del Mundo.  
Llamadas a fijos y m?viles desde 1 c?ntimo por minuto.  
[http://es.voice.yahoo.com](http://es.voice.yahoo.com)

---

<div class="post-metadata">

**Author:** ![Miguel\_Pragier](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/m/ad7895/32.png) [@Miguel\_Pragier](https://discourse.libsdl.org/u/Miguel_Pragier)\
**Post date:** [June 4, 2007, 7:18pm UTC](https://discourse.libsdl.org/t/sdl-net-multiserver-exhausting-networking-re-sources/14582/3 "2007-06-04T19:18:31Z")

</div>

What?

2007/6/4, Roger D Vargas \<luo\_hei at yahoo.es\>:\>

> Port to linux?
> 
> miguel escribi?:
> 
> > Hi, everybody.
> > 
> > I built a server in SDL\_Net. One server to ten clients.
> > 
> > This server runs on a WinXP machine nicely configured. I call this  
> > machine “server machine”.
> > 
> > Everything seems ok, but two days after start, the server machine  
> > already has  
> > no more networking resources. You can’t navigate, can’t run NETSTAT or  
> > even  
> > IPCONFIG. The O.S. message is “There’s no sufficient resources”.
> > 
> > The RAM memory consume is OK. Only the networking is affected.
> > 
> > Any of you have already passed by this kind of trouble?
> > 
> > Any tip? Sugestions?
> > 
> > * * *
> > 
> > SDL mailing list  
> > SDL at [lists.libsdl.org](http://lists.libsdl.org)  
> > [http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org](http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)
> 
> –  
> [http://dsgp.blogspot.com](http://dsgp.blogspot.com) | Linux, programaci?n, juegos  
> Have no place I can be since I found Serenity  
> But you can’t take the sky from me
> 
> * * *
> 
> LLama Gratis a cualquier PC del Mundo.  
> Llamadas a fijos y m?viles desde 1 c?ntimo por minuto.  
> [http://es.voice.yahoo.com](http://es.voice.yahoo.com)
> 
> * * *
> 
> SDL mailing list  
> SDL at [lists.libsdl.org](http://lists.libsdl.org)  
> [http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org](http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)

---

<div class="post-metadata">

**Author:** ![Paulo\_Pinto](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/p/7cd45c/32.png) [@Paulo\_Pinto](https://discourse.libsdl.org/u/Paulo_Pinto)\
**Post date:** [June 4, 2007, 7:21pm UTC](https://discourse.libsdl.org/t/sdl-net-multiserver-exhausting-networking-re-sources/14582/4 "2007-06-04T19:21:04Z")

</div>

That seems like a handle leak.

Are you processing your network conections properly?

miguel schrieb:\> Hi, everybody.

> I built a server in SDL\_Net. One server to ten clients.
> 
> This server runs on a WinXP machine nicely configured. I call this  
> machine “server machine”.
> 
> Everything seems ok, but two days after start, the server machine already has  
> no more networking resources. You can’t navigate, can’t run NETSTAT or even  
> IPCONFIG. The O.S. message is “There’s no sufficient resources”.
> 
> The RAM memory consume is OK. Only the networking is affected.
> 
> Any of you have already passed by this kind of trouble?
> 
> Any tip? Sugestions?
> 
> * * *
> 
> SDL mailing list  
> SDL at [lists.libsdl.org](http://lists.libsdl.org)  
> [http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org](http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)

---

<div class="post-metadata">

**Author:** ![Paulo\_Pinto](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/p/7cd45c/32.png) [@Paulo\_Pinto](https://discourse.libsdl.org/u/Paulo_Pinto)\
**Post date:** [June 4, 2007, 7:25pm UTC](https://discourse.libsdl.org/t/sdl-net-multiserver-exhausting-networking-re-sources/14582/5 "2007-06-04T19:25:00Z")

</div>

If his code has resource leaks, porting to another OS won’t help.

And besides, Windows can also be quite stable.

Miguel Pragier schrieb:\> What?

> 2007/6/4, Roger D Vargas \<luo\_hei at yahoo.es \<mailto:luo\_hei at yahoo.es\>\>:
> 
> ```
> Port to linux?
> 
> miguel escribi?:
> > Hi, everybody.
> >
> > I built a server in SDL_Net. One server to ten clients.
> >
> > This server runs on a WinXP machine nicely configured. I call this
> > machine "server machine".
> >
> > Everything seems ok, but two days after start, the server
> machine already has
> > no more networking resources. You can't navigate, can't run
> NETSTAT or even
> > IPCONFIG. The O.S. message is "There's no sufficient resources".
> >
> > The RAM memory consume is OK. Only the networking is affected.
> >
> > Any of you have already passed by this kind of trouble?
> >
> > Any tip? Sugestions?
> >
> >
> >
> >
> > _______________________________________________
> > SDL mailing list
> > SDL at lists.libsdl.org <mailto:SDL at lists.libsdl.org>
> > http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
> >
> 
> --
> http://dsgp.blogspot.com | Linux, programaci?n, juegos
> Have no place I can be since I found Serenity
> But you can't take the sky from me
> 
> ______________________________________________
> LLama Gratis a cualquier PC del Mundo.
> Llamadas a fijos y m?viles desde 1 c?ntimo por minuto.
> http://es.voice.yahoo.com
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org <mailto:SDL at lists.libsdl.org>
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
> 
> ```
> 
> * * *
> 
> * * *
> 
> SDL mailing list  
> SDL at [lists.libsdl.org](http://lists.libsdl.org)  
> [http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org](http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)

---

<div class="post-metadata">

**Author:** ![Miguel\_Pragier](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/m/ad7895/32.png) [@Miguel\_Pragier](https://discourse.libsdl.org/u/Miguel_Pragier)\
**Post date:** [June 4, 2007, 7:27pm UTC](https://discourse.libsdl.org/t/sdl-net-multiserver-exhausting-networking-re-sources/14582/6 "2007-06-04T19:27:48Z")

</div>

That’s the question I was waiting for.

Look the routine wich turnOn the listeners:

IPaddress ip;

Servidor.SocketSet = SDLNet\_AllocSocketSet(QTD\_MAX\_CLIENTES+2);

if( !Servidor.SocketSet ) exit(-1);

if(SDLNet\_ResolveHost(&ip, NULL, Config.Porta\_Arcano) == -1) exit(-1);

Servidor.sckArcano = SDLNet\_TCP\_Open(&ip);

if( !Servidor.sckArcano ) exit(-1);

SDLNet\_TCP\_AddSocket(Servidor.SocketSet, Servidor.sckArcano);

Now, the NewClientAdmission routine:

void SRV\_TestarSockets()

{

int rArc;

int i = 0;

rArc = SDLNet\_CheckSockets(Servidor.SocketSet, 10);

if( rArc == -1 )

{

LOG\_FRegistrar(“SDLNet\_CheckSockets: %s\n”, SDLNet\_GetError());

return;

}

if( !rArc )

return;

if( SDLNet\_SocketReady(Servidor.sckArcano) )

{

SRV\_Registrar\_Arcano();

Servidor.HouveAtividade = 1;

return;

}

for(i=0; i\<Servidor.ClientesConectados; i++)

{

if( SDLNet\_SocketReady(Clientes[i].sckArcano) )

{

char msg[STR\_100];

char str[STR\_100];

int r;

memset(msg, 0, STR\_100);

memset(str, 0, STR\_100);

r = SDLNet\_TCP\_Recv(Clientes[i].sckArcano, msg, STR\_100);

if( r == -1 )

{

SRV\_DesconectarArcano(i);

Servidor.HouveAtividade = 1;

continue;

}

if( r == 0 )

{

SRV\_DesconectarArcano(i);

Servidor.HouveAtividade = 1;

continue;

}

SRV\_ExtrairComando(msg, str);

if( strlen(str) \> 0 )

{

Servidor.HouveAtividade = 1;

SRV\_InterpretarComando( i, str );

}

}

}

for(i=0; i\<Servidor.ClientesConectados; i++)

{

if( SDLNet\_SocketReady(Clientes[i].sckAcumulado) )

{

char msg[STR\_100];

char str[STR\_100];

int r;

memset(msg, 0, STR\_100);

memset(str, 0, STR\_100);

r = SDLNet\_TCP\_Recv(Clientes[i].sckAcumulado, msg, STR\_100);

if( ( r == -1 ) || ( r == 0 ) )

{

Clientes[i].sckAcumulado = NULL;

continue;

}

SRV\_ExtrairComando(msg, str);

if( strlen(str) \> 0 )

{

SRV\_InterpretarComando( i, str );

Servidor.HouveAtividade = 1;

}

}

}

}

---

<div class="post-metadata">

**Author:** ![Miguel\_Pragier](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/m/ad7895/32.png) [@Miguel\_Pragier](https://discourse.libsdl.org/u/Miguel_Pragier)\
**Post date:** [June 4, 2007, 7:33pm UTC](https://discourse.libsdl.org/t/sdl-net-multiserver-exhausting-networking-re-sources/14582/7 "2007-06-04T19:33:42Z")

</div>

This is the routine that disconnetcs a client.

void SRV\_DesconectarArcano( const int cliente )

{

SDLNet\_TCP\_DelSocket(Servidor.SocketSet, Clientes[cliente].sckArcano);

if( Clientes[cliente].sckArcano )

{

SDLNet\_TCP\_Close(Clientes[cliente].sckArcano);

Clientes[cliente].sckArcano = NULL;

}}

AM I IN TROUBLE?

😉

---

<div class="post-metadata">

**Author:** ![Paulo\_Pinto](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/p/7cd45c/32.png) [@Paulo\_Pinto](https://discourse.libsdl.org/u/Paulo_Pinto)\
**Post date:** [June 4, 2007, 8:40pm UTC](https://discourse.libsdl.org/t/sdl-net-multiserver-exhausting-networking-re-sources/14582/8 "2007-06-04T20:40:13Z")

</div>

I’m not familiar with SDLNet, but your code seems to  
be ok.

Try to monitor your process handle’s usage with the taskmanager.

Cheers,  
Paulo

Miguel Pragier schrieb:\> This is the routine that disconnetcs a client.

> void
> 
> SRV\_DesconectarArcano( const int cliente )
> 
> {
> 
> SDLNet\_TCP\_DelSocket(Servidor.SocketSet, Clientes[cliente].sckArcano);
> 
> if( Clientes[cliente].sckArcano )
> 
> {
> 
> SDLNet\_TCP\_Close(Clientes[cliente].sckArcano);
> 
> Clientes[cliente].sckArcano = NULL;
> 
> }}
> 
> AM I IN TROUBLE?
> 
> 😉
> 
> * * *
> 
> * * *
> 
> SDL mailing list  
> SDL at [lists.libsdl.org](http://lists.libsdl.org)  
> [http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org](http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)

---

<div class="post-metadata">

**Author:** ![Sitsofe\_Wheeler](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/c4cdca/32.png) [@Sitsofe\_Wheeler](https://discourse.libsdl.org/u/Sitsofe_Wheeler)\
**Post date:** [June 4, 2007, 11:22pm UTC](https://discourse.libsdl.org/t/sdl-net-multiserver-exhausting-networking-re-sources/14582/9 "2007-06-04T23:22:16Z")

</div>

Be warned that by default XP limits you to a maximum of 10 in bound  
connections (see [http://support.microsoft.com/kb/314882](http://support.microsoft.com/kb/314882) ). This may not  
necessarily be the problem you are seeing though.On Mon, 2007-06-04 at 17:42 +0000, miguel wrote:

> Everything seems ok, but two days after start, the server machine already has  
> no more networking resources. You can’t navigate, can’t run NETSTAT or even  
> IPCONFIG. The O.S. message is “There’s no sufficient resources”.
> 
> The RAM memory consume is OK. Only the networking is affected.  
> Any tip? Sugestions?

–  
Sitsofe | [Welcome to slant!](http://sucs.org/~sits/)
