|
You last visited: Today at 23:03
Advertisement
What about coding an efficient socket system?
Discussion on What about coding an efficient socket system? within the CO2 Private Server forum part of the Conquer Online 2 category.
08/07/2010, 14:34
|
#1
|
elite*gold: 0
Join Date: Jul 2006
Posts: 2,216
Received Thanks: 794
|
What about coding an efficient socket system?
I want to start a new project from scratch, and I thought about using my sockets from my last unfinished projects until I saw the .NET 3.5 methods. What do you guys think about the methods used in the sample which was released by MS? I`m talking about the BufferManager approach, and the pool for the SocketAsyncEventArgs. It seems nice to me, I implemented this in my project, with some modifications to fit my needs, what do you guys think about it?
#edit : Also, would it be better if I coded the sockets in native?
|
|
|
08/07/2010, 14:38
|
#2
|
elite*gold: 28
Join Date: Jun 2010
Posts: 2,226
Received Thanks: 868
|
Does not matter really, Just use Async sockets. Easy to work around I'm learning to use those as well.
|
|
|
08/07/2010, 14:45
|
#3
|
elite*gold: 0
Join Date: Jul 2006
Posts: 2,216
Received Thanks: 794
|
Lol, that`s not what I`m talking about. This sample uses a buffer that is allocated for all users, and every user is granted a 'piece' of it. This seems a good method for me, as you don`t have to create new buffers for everyone, even if it limits the amount of users. You don`t have to allocate dynamic memory for everyone, you have one large buffer.
|
|
|
08/07/2010, 14:46
|
#4
|
elite*gold: 28
Join Date: Jun 2010
Posts: 2,226
Received Thanks: 868
|
Just tryed to say something smart  I'm not the best in that area as I've just started learning all this buffer, static buffer ****,
|
|
|
08/07/2010, 20:18
|
#5
|
elite*gold: 1142
Join Date: Aug 2006
Posts: 2,464
Received Thanks: 1,162
|
Quote:
Originally Posted by Eliminationn
Does not matter really, Just use Async sockets. Easy to work around I'm learning to use those as well.
|
Made me giggle
|
|
|
08/07/2010, 20:32
|
#6
|
elite*gold: 0
Join Date: Jul 2006
Posts: 2,216
Received Thanks: 794
|
Quote:
Originally Posted by EmmeTheCoder
Made me giggle
|
And your point related to the topic would be...?
|
|
|
08/07/2010, 20:44
|
#7
|
elite*gold: 0
Join Date: Jan 2008
Posts: 1,444
Received Thanks: 1,176
|
You have 1 or 100 clients and you will use the same memory. A bit stupid to allocate like 100MB for 1 client... I think it's better in a way to allocate a little 2MB for each client. Something like this.
|
|
|
08/07/2010, 23:12
|
#8
|
elite*gold: 0
Join Date: Nov 2009
Posts: 390
Received Thanks: 321
|
Even 2 mb is too much
Anyways imho best way is dynamically allocating memory per client.
|
|
|
08/07/2010, 23:39
|
#9
|
elite*gold: 0
Join Date: Jul 2006
Posts: 2,216
Received Thanks: 794
|
But dynamic memory is allocating memory from the heap, right? And allocating memory from the stack should be faster.
|
|
|
08/08/2010, 00:15
|
#10
|
elite*gold: 0
Join Date: Nov 2009
Posts: 390
Received Thanks: 321
|
Speed difference is too small, anyhow that won't be an issue because if i'm not mistaken you're going for managed which is slow enough anyway..
On the other hand if you're going for native then you could do better mem. managing by implementing a mem. pool.
And if you're aiming for top notch performance/speed consider writing it for linux/unix, check out beej's guide for a crash course.
|
|
|
08/08/2010, 10:03
|
#11
|
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
|
Each connection should have its own buffer if your using sockets, its much easier to manage. One of the main bottle necks is where you split up the packets to be handled so make sure that aspect is small, simple and very efficient.
For the buffer btw, since your dealing with the client's packets you dont need a big buffer, so you can happily allocate 2048 bytes and have done with it without worrying about incomplete packets due to filling the buffer, because you'll never fill it.
|
|
|
08/08/2010, 16:52
|
#12
|
elite*gold: 0
Join Date: Jan 2008
Posts: 1,444
Received Thanks: 1,176
|
Quote:
Originally Posted by Nullable
Even 2 mb is too much
Anyways imho best way is dynamically allocating memory per client.
|
I know. In general, I allocate between 1 and 3 Ko. Depends of the protocol.
|
|
|
08/08/2010, 17:53
|
#13
|
elite*gold: 0
Join Date: Jun 2009
Posts: 787
Received Thanks: 314
|
Quote:
Originally Posted by Korvacs
Each connection should have its own buffer if your using sockets, its much easier to manage. One of the main bottle necks is where you split up the packets to be handled so make sure that aspect is small, simple and very efficient.
For the buffer btw, since your dealing with the client's packets you dont need a big buffer, so you can happily allocate 2048 bytes and have done with it without worrying about incomplete packets due to filling the buffer, because you'll never fill it.
|
Possible that it would fill in the case of someones net dropping and then coming back before they time out (of course depends on the time they've dropped and how much data they would've sent in that time). Unlikely, and as long as you have proper checks you can drop someone who lags that bad.
|
|
|
08/09/2010, 01:04
|
#14
|
elite*gold: 0
Join Date: Jan 2008
Posts: 1,444
Received Thanks: 1,176
|
Quote:
Originally Posted by _tao4229_
Possible that it would fill in the case of someones net dropping and then coming back before they time out (of course depends on the time they've dropped and how much data they would've sent in that time). Unlikely, and as long as you have proper checks you can drop someone who lags that bad.
|
TQ has a packet for the lag. Just nobody use it.
|
|
|
08/10/2010, 12:37
|
#15
|
elite*gold: 0
Join Date: Sep 2008
Posts: 1,683
Received Thanks: 506
|
Quote:
Originally Posted by CptSky
TQ has a packet for the lag. Just nobody use it.
|
Which packet?
|
|
|
Similar Threads
|
[AD] ZhyperMU | Full Season 4 | Socket System + Anti Cheat | 24/7 Dedicated Server
10/28/2011 - General Gaming Discussion - 1 Replies
http://i25.tinypic.com/316lzt5.gif
WELCOME TO ZHYPERMU
ZHYPERMU SEASON4 !!
Server Is ONLINE]
Server Is Up For 24/7!
You are in a place with no way out (...)
-
|
socket system tut ?
09/09/2010 - Silkroad Online - 7 Replies
hello. i`m looking for a socket system tutorial. any help please?
|
[Release] Socket System for Hybrids Source!
05/12/2010 - CO2 PServer Guides & Releases - 22 Replies
Apple Pie is amazing!!!!
|
Efficient farming
06/07/2006 - Lineage 2 - 2 Replies
As I just got another account, I ask myself how to farm efficiently with just one toon, using walker or superman. Would a scavenger be a good idea? Or any other class? Which level should the toon be and at which location should it hunt?
Thanks in advance.
|
All times are GMT +1. The time now is 23:05.
|
|