SDL_Net Drops Packets

I’m trying to make a multi-player game. When the player logs into the
server the server then sends all the players game data to syncronize the
new player. but it can only make about 4 consequative calls to
SDLNet_TCP_Send before everything else is dropped. So far I have bypassed
this problem by putting in SDL_Delay(100); after each SDLNet_TCP_Send. But
I don’t like doing this and would like to fix the problem. Any ideas?

It sounds like the problem is on your client side

Your computer has a buffer for network data but it’s only so big and when it
gets full it will start dropping packets

You might want to make sure you are receiving data in your client program in
a timely fashion.

That might not be the problem but the symptoms sound like it> ----- Original Message -----

From: sdl-bounces+atrix2=cox.net@libsdl.org
[mailto:sdl-bounces+atrix2=cox.net at libsdl.org] On Behalf Of
norco at ten-arc.net
Sent: Saturday, April 08, 2006 9:51 PM
To: sdl at libsdl.org
Subject: [SDL] SDL_Net Drops Packets

I’m trying to make a multi-player game. When the player logs into the
server the server then sends all the players game data to syncronize the
new player. but it can only make about 4 consequative calls to
SDLNet_TCP_Send before everything else is dropped. So far I have bypassed
this problem by putting in SDL_Delay(100); after each SDLNet_TCP_Send. But
I don’t like doing this and would like to fix the problem. Any ideas?


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Thanks for replying. it sure beat sitting in #sdl and everyone ignoring me
as the chat about script kiddies and how to ban them… I suppose its the
router. I made a similar application using SocketWrench but was able to
fix the problem with a sleep of 1ms and never lost any sends as long as i
had that 1 ms. but with sdlnet, if i use 10ms it sometimes loses packets.
I suppose I’ll have to impliment an ack echo protocol for each recv.
althought its going become difficault since this is a multi threaded
server and ill have to do something special so all the threads wait
correctly… although it seems fine with 50ms delay so I’ll try with that…
its really just annoying. I was hoping sdlnet would have its own packet
queue of some sort like that aweful DirectPlay has… but good work anyways
and thanks, I’m sure I’ll contact you later about FPS problems I have on
some computers…> It sounds like the problem is on your client side

Your computer has a buffer for network data but it’s only so big and when
it
gets full it will start dropping packets

You might want to make sure you are receiving data in your client program
in
a timely fashion.

That might not be the problem but the symptoms sound like it

-----Original Message-----
From: sdl-bounces+atrix2=cox.net at libsdl.org
[mailto:sdl-bounces+atrix2=cox.net at libsdl.org] On Behalf Of
@norco_at_ten-arc.net
Sent: Saturday, April 08, 2006 9:51 PM
To: sdl at libsdl.org
Subject: [SDL] SDL_Net Drops Packets

I’m trying to make a multi-player game. When the player logs into the
server the server then sends all the players game data to syncronize the
new player. but it can only make about 4 consequative calls to
SDLNet_TCP_Send before everything else is dropped. So far I have bypassed
this problem by putting in SDL_Delay(100); after each SDLNet_TCP_Send. But
I don’t like doing this and would like to fix the problem. Any ideas?


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Another option is to use Net2
(http://gameprogrammer.com/net2/net2-0.html) which is event driven.

ChrisOn 4/9/06, norco at ten-arc.net wrote:

Thanks for replying. it sure beat sitting in #sdl and everyone ignoring me
as the chat about script kiddies and how to ban them… I suppose its the
router. I made a similar application using SocketWrench but was able to
fix the problem with a sleep of 1ms and never lost any sends as long as i
had that 1 ms. but with sdlnet, if i use 10ms it sometimes loses packets.
I suppose I’ll have to impliment an ack echo protocol for each recv.
althought its going become difficault since this is a multi threaded
server and ill have to do something special so all the threads wait
correctly… although it seems fine with 50ms delay so I’ll try with that…
its really just annoying. I was hoping sdlnet would have its own packet
queue of some sort like that aweful DirectPlay has… but good work anyways
and thanks, I’m sure I’ll contact you later about FPS problems I have on
some computers…


E-Mail: Chris Nystrom
http://www.newio.org/
AIM: nystromchris

norco at ten-arc.net wrote:

I suppose I’ll have to impliment an ack echo protocol for each recv.

don’t think so, tcp does already the ack thing for you.

although it seems fine with 50ms delay so I’ll try with that… its
really just annoying. I was hoping sdlnet would have its own packet
queue of some sort like that aweful DirectPlay has…

sdlnet does no seperate buffering on its own, it’s just a thin wrapper
around send/rcve, the OS is responsible for buffering on both sides.
when the receive buffer on one side gets full, the send() on the other
side will block, until the client is ready to receive data again.
unless you are using non-blocking IO. then the send() will return an
error. TCP will NEVER silently drop any data.

inserting random delays to cure some strange symptoms, sounds like
masquarading an ugly bug in your code. even more as you said your
server is multithreaded. if its really your router, throw it away -
it’s crap.

also keep in mind that TCP does not preserve message bounderies. you
must always be sure on your own where the last packet ends and the new
one begins.

best regards …
clemens

I’m trying to make a multi-player game. When the player logs into the
server the server then sends all the players game data to syncronize the
new player. but it can only make about 4 consequative calls to
SDLNet_TCP_Send before everything else is dropped. So far I have bypassed
this problem by putting in SDL_Delay(100); after each SDLNet_TCP_Send. But
I don’t like doing this and would like to fix the problem. Any ideas?

SDLNet_TCP_Send() should never drop packets unless there was an OS or
network level error. It should block until the entire buffer was sent,
and TCP promises that the other side will definitely receive it, too.

Make sure you check the return value from SDLNet_TCP_Send and if it’s
smaller than you expected, you might want to look at the function in a
debugger and see why it failed…SDL_net doesn’t have a wrapper over
errno/OSStatus/WSAGetLastError() to let you determine this from your app.

If you still have problems, please post the relevant piece of your code,
if you can, and we might be able to spot something.

–ryan.

I’d like to see some code for the send & recv routines you have (both
server and client side) before accusing SDLNet of not working. I have
created a number of multiplayer games using SDLNet on the client end,
but I never used it on the server end because of the lack of
non-blocking sockets. I believe you can achieve this with other libs but
I’m not sure. I always just wrote my own server routines. I think that
is your best bet unless the server needs to run on multiple OSes.On Sat, 2006-04-08 at 23:51 -0500, norco at ten-arc.net wrote:

I’m trying to make a multi-player game. When the player logs into the
server the server then sends all the players game data to syncronize the
new player. but it can only make about 4 consequative calls to
SDLNet_TCP_Send before everything else is dropped. So far I have bypassed
this problem by putting in SDL_Delay(100); after each SDLNet_TCP_Send. But
I don’t like doing this and would like to fix the problem. Any ideas?


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

-John Josef
-Technical Director, Glass Hat Software Inc.
-Phone: (407)-401-9907
-Fax: (407)-401-9039

accusing SDLNet of not working

I always accuse everything when theres a problem. If I counted the number
of times I flamed microsoft out loud in this quiet room … then finding
out it’s my fault. This problem still exists even with 100ms delay between
sends and I am testing over 100mb lan. I havent tried much but I did, on
the client side thats not getting the packets, add in a buffer log
routine. all I do is when len = SDLNet_TCP_Recv(sock,buff,5000); fires i
have writelog(buff, len); and accordign to the log, its not getting any
packets after the server sends the first couple unless I have a
significant delay. But I do believe it’s still my fault or else everyone
would be having this problem. I don’t think its the router, I made another
game with winsock and it never drops packets aslong as i make sure the
socket has a ready flag before sending. does sdl_net have a ready flag?> I’d like to see some code for the send & recv routines you have (both

server and client side) before accusing SDLNet of not working. I have
created a number of multiplayer games using SDLNet on the client end,
but I never used it on the server end because of the lack of
non-blocking sockets. I believe you can achieve this with other libs but
I’m not sure. I always just wrote my own server routines. I think that
is your best bet unless the server needs to run on multiple OSes.

On Sat, 2006-04-08 at 23:51 -0500, @norco_at_ten-arc.net wrote:

I’m trying to make a multi-player game. When the player logs into the
server the server then sends all the players game data to syncronize the
new player. but it can only make about 4 consequative calls to
SDLNet_TCP_Send before everything else is dropped. So far I have
bypassed
this problem by putting in SDL_Delay(100); after each SDLNet_TCP_Send.
But
I don’t like doing this and would like to fix the problem. Any ideas?


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

-John Josef
-Technical Director, Glass Hat Software Inc.
-Phone: (407)-401-9907
-Fax: (407)-401-9039


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

OK IT’S MY FAULT I FIXED IT GOD DAMN IM NOT EVEN GOING SAY WHAT I DID IT’S
EMBARRASSING
… thanks for all the indepth replies>> accusing SDLNet of not working

I always accuse everything when theres a problem. If I counted the number
of times I flamed microsoft out loud in this quiet room … then finding
out it’s my fault. This problem still exists even with 100ms delay between
sends and I am testing over 100mb lan. I havent tried much but I did, on
the client side thats not getting the packets, add in a buffer log
routine. all I do is when len = SDLNet_TCP_Recv(sock,buff,5000); fires i
have writelog(buff, len); and accordign to the log, its not getting any
packets after the server sends the first couple unless I have a
significant delay. But I do believe it’s still my fault or else everyone
would be having this problem. I don’t think its the router, I made another
game with winsock and it never drops packets aslong as i make sure the
socket has a ready flag before sending. does sdl_net have a ready flag?

I’d like to see some code for the send & recv routines you have (both
server and client side) before accusing SDLNet of not working. I have
created a number of multiplayer games using SDLNet on the client end,
but I never used it on the server end because of the lack of
non-blocking sockets. I believe you can achieve this with other libs but
I’m not sure. I always just wrote my own server routines. I think that
is your best bet unless the server needs to run on multiple OSes.

On Sat, 2006-04-08 at 23:51 -0500, @norco_at_ten-arc.net wrote:

I’m trying to make a multi-player game. When the player logs into the
server the server then sends all the players game data to syncronize
the
new player. but it can only make about 4 consequative calls to
SDLNet_TCP_Send before everything else is dropped. So far I have
bypassed
this problem by putting in SDL_Delay(100); after each SDLNet_TCP_Send.
But
I don’t like doing this and would like to fix the problem. Any ideas?


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

-John Josef
-Technical Director, Glass Hat Software Inc.
-Phone: (407)-401-9907
-Fax: (407)-401-9039


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

OK IT’S MY FAULT I FIXED IT GOD DAMN IM NOT EVEN GOING SAY WHAT I DID IT’S
EMBARRASSING
… thanks for all the indepth replies

Yep, I found sometimes just discussing the problems is enough to
understand it with a new perspective and thing can suddenly become
obvious… and as you said embarrassing!

Personnally, I say as long as you fixed the issue, that’s all that
counts, grats!

Simon