Hi!
I'm writing a simple 3D First person shooter game. It is a multiplayer
game, where all the players connect
to one server.
I'm using the System.Net.Sockets.Socket class for communication over TCP
protocol (I know that good games
use UDP).
I report changes to the server through simple Messages (a messages would
look like: [messOwner, Type, ...]),
where a typical message is about 20-30 bytes in size.
So if a client moves I send a message ([client1, Move, NewPosition]) to
the server and the server then transmits
this message to the other clients in the game.
The messages is sent using the Socket.Send(byte[]) method.
A typical server loop looks like this:
while (true)
{
socket.Receive(buffer);
Message m = DecodeMessage(buffer); // I just create a message
object from the buffer here
MyMessageQueue.Enqueue(m); // the message is enqueued in a simple
message queue and is processed on another thread
}
The problem is this:
If a client is constantly moving, it is sending a Move message each
frame (about 40-60 messages on average)
and the server doesn't GET all of them! Even if there is only one player
- over a LAN network only 30% of all messages arrives (if the server and
the client
are on the same machine all the messages get there). I know this because
I've added counters on both sides .
The message queue works very well... what ever get's in there - gets
processed. Could the problem be in the Receive method?
Is it possible that, while I'm processing the message, the client sends
more than one message in that time (overwrites what was there before)
and the server just
picks up the last data received?
If so... anyway to get around that? (While still sending information
every frame if neccessary - I will changes this only as a last resort :(
).
thanks,
saso 4 2145
Check the result of the sent method to see if all bytes are sent.
perhaps you are overflowing the tcpip buffer
"Sačo Zagoranski" <sa*************@guest.arnes.si> wrote in message news:d6**********@planja.arnes.si...
Hi!
I'm writing a simple 3D First person shooter game. It is a multiplayer game, where all the players connect
to one server.
I'm using the System.Net.Sockets.Socket class for communication over TCP protocol (I know that good games
use UDP).
I report changes to the server through simple Messages (a messages would look like: [messOwner, Type, ...]),
where a typical message is about 20-30 bytes in size.
So if a client moves I send a message ([client1, Move, NewPosition]) to the server and the server then transmits
this message to the other clients in the game.
The messages is sent using the Socket.Send(byte[]) method.
A typical server loop looks like this:
while (true)
{
socket.Receive(buffer);
Message m = DecodeMessage(buffer); // I just create a message object from the buffer here
MyMessageQueue.Enqueue(m); // the message is enqueued in a simple message queue and is processed on another thread
}
The problem is this:
If a client is constantly moving, it is sending a Move message each frame (about 40-60 messages on average)
and the server doesn't GET all of them! Even if there is only one player - over a LAN network only 30% of all messages arrives (if the server and the client
are on the same machine all the messages get there). I know this because I've added counters on both sides .
The message queue works very well... what ever get's in there - gets processed. Could the problem be in the Receive method?
Is it possible that, while I'm processing the message, the client sends more than one message in that time (overwrites what was there before) and the server just
picks up the last data received?
If so... anyway to get around that? (While still sending information every frame if neccessary - I will changes this only as a last resort :( ).
thanks,
saso
I have checked it...
the number of bytes send by socket.send(...) are the same as the amount
that should have been send...
about 10kB in a minute but the server receives only 30% of the data.
What do you think about this possibility?
I wrote this in the first post:
Is it possible that, while I'm processing the message, the client sends
more than one message in that time (overwrites what was there before)
and the server just
picks up the last data received?
saso
_____
Od: Sagaert Johan [mailto:RE*************@hotmail.com]
Poslano: 22. maj 2005 20:24
Objavljeno v: microsoft.public.dotnet.languages.csharp
Pogovor: Socket communication problem
Zadeva: Re: Socket communication problem
Check the result of the sent method to see if all bytes are sent.
perhaps you are overflowing the tcpip buffer
"Sačo Zagoranski" <sa*************@guest.arnes.si> wrote in message
news:d6**********@planja.arnes.si...
Hi!
I'm writing a simple 3D First person shooter game. It is a multiplayer
game, where all the players connect
to one server.
I'm using the System.Net.Sockets.Socket class for communication over TCP
protocol (I know that good games
use UDP).
I report changes to the server through simple Messages (a messages would
look like: [messOwner, Type, ...]),
where a typical message is about 20-30 bytes in size.
So if a client moves I send a message ([client1, Move, NewPosition]) to
the server and the server then transmits
this message to the other clients in the game.
The messages is sent using the Socket.Send(byte[]) method.
A typical server loop looks like this:
while (true)
{
socket.Receive(buffer);
Message m = DecodeMessage(buffer); // I just create a message
object from the buffer here
MyMessageQueue.Enqueue(m); // the message is enqueued in a simple
message queue and is processed on another thread
}
The problem is this:
If a client is constantly moving, it is sending a Move message each
frame (about 40-60 messages on average)
and the server doesn't GET all of them! Even if there is only one player
- over a LAN network only 30% of all messages arrives (if the server and
the client
are on the same machine all the messages get there). I know this because
I've added counters on both sides .
The message queue works very well... what ever get's in there - gets
processed. Could the problem be in the Receive method?
Is it possible that, while I'm processing the message, the client sends
more than one message in that time (overwrites what was there before)
and the server just
picks up the last data received?
If so... anyway to get around that? (While still sending information
every frame if neccessary - I will changes this only as a last resort :(
).
thanks,
saso
I have found the problem (not the solution :( )
One Move sends 24 bytes over the network. If the player moves very
slowly everything is ok...
but if you move very fast the Receive method receives MORE than 24 bytes
(up to 200!)...
how to get around that?
_____
Od: Saso Zagoranski [mailto:sa*************@guest.arnes.si]
Poslano: 22. maj 2005 22:47
Objavljeno v: microsoft.public.dotnet.languages.csharp
Pogovor: Socket communication problem
Zadeva: Re: Socket communication problem
I have checked it...
the number of bytes send by socket.send(...) are the same as the amount
that should have been send...
about 10kB in a minute but the server receives only 30% of the data.
What do you think about this possibility?
I wrote this in the first post:
Is it possible that, while I'm processing the message, the client sends
more than one message in that time (overwrites what was there before)
and the server just
picks up the last data received?
saso
_____
Od: Sagaert Johan [mailto:RE*************@hotmail.com]
Poslano: 22. maj 2005 20:24
Objavljeno v: microsoft.public.dotnet.languages.csharp
Pogovor: Socket communication problem
Zadeva: Re: Socket communication problem
Check the result of the sent method to see if all bytes are sent.
perhaps you are overflowing the tcpip buffer
"Sačo Zagoranski" <sa*************@guest.arnes.si> wrote in message
news:d6**********@planja.arnes.si...
Hi!
I'm writing a simple 3D First person shooter game. It is a multiplayer
game, where all the players connect
to one server.
I'm using the System.Net.Sockets.Socket class for communication over TCP
protocol (I know that good games
use UDP).
I report changes to the server through simple Messages (a messages would
look like: [messOwner, Type, ...]),
where a typical message is about 20-30 bytes in size.
So if a client moves I send a message ([client1, Move, NewPosition]) to
the server and the server then transmits
this message to the other clients in the game.
The messages is sent using the Socket.Send(byte[]) method.
A typical server loop looks like this:
while (true)
{
socket.Receive(buffer);
Message m = DecodeMessage(buffer); // I just create a message
object from the buffer here
MyMessageQueue.Enqueue(m); // the message is enqueued in a simple
message queue and is processed on another thread
}
The problem is this:
If a client is constantly moving, it is sending a Move message each
frame (about 40-60 messages on average)
and the server doesn't GET all of them! Even if there is only one player
- over a LAN network only 30% of all messages arrives (if the server and
the client
are on the same machine all the messages get there). I know this because
I've added counters on both sides .
The message queue works very well... what ever get's in there - gets
processed. Could the problem be in the Receive method?
Is it possible that, while I'm processing the message, the client sends
more than one message in that time (overwrites what was there before)
and the server just
picks up the last data received?
If so... anyway to get around that? (While still sending information
every frame if neccessary - I will changes this only as a last resort :(
).
thanks,
saso
I solved it... If I receive a lot of data in one package I just split it
in more messages.
However... since there are so many messages going over the network,
everything
still works slowly... :(
_____
Od: Saso Zagoranski [mailto:sa*************@guest.arnes.si]
Poslano: 22. maj 2005 23:21
Objavljeno v: microsoft.public.dotnet.languages.csharp
Pogovor: Socket communication problem
Zadeva: Re: Socket communication problem
I have found the problem (not the solution :( )
One Move sends 24 bytes over the network. If the player moves very
slowly everything is ok...
but if you move very fast the Receive method receives MORE than 24 bytes
(up to 200!)...
how to get around that?
_____
Od: Saso Zagoranski [mailto:sa*************@guest.arnes.si]
Poslano: 22. maj 2005 22:47
Objavljeno v: microsoft.public.dotnet.languages.csharp
Pogovor: Socket communication problem
Zadeva: Re: Socket communication problem
I have checked it...
the number of bytes send by socket.send(...) are the same as the amount
that should have been send...
about 10kB in a minute but the server receives only 30% of the data.
What do you think about this possibility?
I wrote this in the first post:
Is it possible that, while I'm processing the message, the client sends
more than one message in that time (overwrites what was there before)
and the server just
picks up the last data received?
saso
_____
Od: Sagaert Johan [mailto:RE*************@hotmail.com]
Poslano: 22. maj 2005 20:24
Objavljeno v: microsoft.public.dotnet.languages.csharp
Pogovor: Socket communication problem
Zadeva: Re: Socket communication problem
Check the result of the sent method to see if all bytes are sent.
perhaps you are overflowing the tcpip buffer
"Sačo Zagoranski" <sa*************@guest.arnes.si> wrote in message
news:d6**********@planja.arnes.si...
Hi!
I'm writing a simple 3D First person shooter game. It is a multiplayer
game, where all the players connect
to one server.
I'm using the System.Net.Sockets.Socket class for communication over TCP
protocol (I know that good games
use UDP).
I report changes to the server through simple Messages (a messages would
look like: [messOwner, Type, ...]),
where a typical message is about 20-30 bytes in size.
So if a client moves I send a message ([client1, Move, NewPosition]) to
the server and the server then transmits
this message to the other clients in the game.
The messages is sent using the Socket.Send(byte[]) method.
A typical server loop looks like this:
while (true)
{
socket.Receive(buffer);
Message m = DecodeMessage(buffer); // I just create a message
object from the buffer here
MyMessageQueue.Enqueue(m); // the message is enqueued in a simple
message queue and is processed on another thread
}
The problem is this:
If a client is constantly moving, it is sending a Move message each
frame (about 40-60 messages on average)
and the server doesn't GET all of them! Even if there is only one player
- over a LAN network only 30% of all messages arrives (if the server and
the client
are on the same machine all the messages get there). I know this because
I've added counters on both sides .
The message queue works very well... what ever get's in there - gets
processed. Could the problem be in the Receive method?
Is it possible that, while I'm processing the message, the client sends
more than one message in that time (overwrites what was there before)
and the server just
picks up the last data received?
If so... anyway to get around that? (While still sending information
every frame if neccessary - I will changes this only as a last resort :(
).
thanks,
saso This discussion thread is closed Replies have been disabled for this discussion. Similar topics
2 posts
views
Thread by Lindstrom Greg - glinds |
last post: by
|
4 posts
views
Thread by faktujaa |
last post: by
|
2 posts
views
Thread by tantiboh |
last post: by
|
3 posts
views
Thread by Ricardo Quintanilla |
last post: by
|
13 posts
views
Thread by coloradowebdev |
last post: by
|
1 post
views
Thread by Mr. Beck |
last post: by
|
8 posts
views
Thread by panko |
last post: by
|
reply
views
Thread by =?Utf-8?B?QWxwZXIgQUtDQVlPWg==?= |
last post: by
|
reply
views
Thread by Mangabasi |
last post: by
| | | | | | | | | | |