Welcome to the RaGEZONE - MMORPG development forums.

SuperSockets [C#] Hold up to 10K connections.

This is a discussion on SuperSockets [C#] Hold up to 10K connections. within the Habbo Releases forums, part of the Habbo Hotel category; ! UPDATED Download: Pack.rar Information SocketListener using async, events and pooling. (Very Stable) Read the 'README' :) Credits 50% Microsoft ...

LyncusMU
Page 1 of 2 12 LastLast
Results 1 to 15 of 27
  1. #1
    Alpha
    Rank
    Member
    Join Date
    Dec 2011
    Posts
    134
    Liked
    39

    SuperSockets [C#] Hold up to 10K connections.

    Tabo Hotel

    ! UPDATED Download: Pack.rar

    Information
    SocketListener using async, events and pooling. (Very Stable)

    Read the 'README' :)

    Credits
    50% Microsoft (Doing examples how to create)
    50% Me (Doing te codes)

    Example(s)

    Pooling
    Code:
            internal SocketAsyncEventArgs Pop()
            {
                lock (this.Pool)
                {
                    return this.Pool.Pop();
                }
            }
    
            internal void Push(SocketAsyncEventArgs item)
            {
                lock (this.Pool)
                {
                    this.Pool.Push(item);
                }
            }
    Async Accepting
    Code:
            private static void WaitForAsync(SocketAsyncEventArgs Args)
            {
                if (Args == null)
                {
                    Args = new SocketAsyncEventArgs();
                    Args.Completed += new EventHandler<SocketAsyncEventArgs>(AcceptAsync_Completed);
                }
                else
                {
                    Args.AcceptSocket = null;
                }
    
                SocketSemaphore.WaitOne();
    
                BaseSocket.AcceptAsync(Args);
            }
    
            private static void HandleAsync(SocketAsyncEventArgs Args)
            {
                try
                {
                    Interlocked.Increment(ref ConnectedAmount);
    
                    var SingleSocketAsync = SocketPool.Pop();
                    var Token = (AsyncUserToken)SingleSocketAsync.UserToken;
    
                    Token.Socket = Args.AcceptSocket;
    
                    var Session = new Session(Interlocked.Increment(ref Counter), Token.Socket, Args);
    
                    Sessions.Add(Session.Id, Session);
    
                    if (!Args.AcceptSocket.ReceiveAsync(SingleSocketAsync))
                    {
                        HandleReceive(SingleSocketAsync);
                    }
                }
                catch { }
                finally { WaitForAsync(Args); }
            }

    Like if you like!


    I use this in (Boolean) : http://forum.ragezone.com/f331/proje...63a-os-808457/
    Last edited by Squard; 09-01-12 at 06:07 PM.

  2. HostKey.com: Unmetered Dedicated servers in the Netherlands
  3. #2
    Member
    Rank
    Subscriber
    Join Date
    Jul 2006
    Posts
    383
    Liked
    200

    Re: SocketListener + Sockets C# [Events, Async, Fast, Hard]

    Well done Wichard, not bad!!! and guys, SocketAsyncEvents is what REALLY holds 10k+ connections in C#

    Why you still using internal btw, do you know what that actually does?

    EDIT: Took a quick look, im sad :(, your not doing it all correctly your missing a few very important things, your not allocated the buffer at startup so its all in the same memory space (the buffer space is handed out to clients on read/write request, it doesn't create a buffer for each use, acts like a buffer pool)


    EDIT 2: Why don't you just make use of SuperSocket? It does everything else for you, just import the project solution into your project as dependencies then use it :D

    Otherwise look here:
    http://www.codeproject.com/KB/IP/soc...eventargs.aspx
    Last edited by matty13; 09-01-12 at 05:31 PM.

  4. #3
    Alpha
    Rank
    Member
    Join Date
    Dec 2011
    Posts
    134
    Liked
    39

    Re: SocketListener + Sockets C# [Events, Async, Fast, Hard]

    Quote Originally Posted by matty13 View Post
    Well done Wichard, not bad!!! and guys, SocketAsyncEvents is what REALLY holds 10k+ connections in C#

    Why you still using internal btw, do you know what that actually does?

    EDIT: Took a quick look, im sad :(, your not doing it all correctly your missing a few very important things, your not allocated the buffer at startup so its all in the same memory space (the buffer space is handed out to clients on read/write request, it doesn't create a buffer for each use, acts like a buffer pool)
    You should help me: [email protected]

  5. #4

  6. #5
    Alpha
    Rank
    Member
    Join Date
    Dec 2011
    Posts
    134
    Liked
    39

    Re: SocketListener + Sockets C# [Events, Async, Fast, Hard]

    I finished the BufferManager.

    Quote Originally Posted by matty13 View Post
    Already got you on msn but your not online to me.
    With BufferManager: Transmission.rar

    Very stable ;D

  7. #6
    Account Upgraded | Title Enabled!
    Rank
    Member +
    Join Date
    Aug 2011
    Location
    England Coder<3
    Posts
    525
    Liked
    104
    Ooh, thanks. Now the users who buy my emulator wont complain about a limit of 5k :/

    Sent from my mobile via Tapatalk.

  8. #7
    Idiots these days...
    Rank
    Member +
    Join Date
    Sep 2009
    Location
    Wales
    Posts
    1,202
    Liked
    213

    Re: SuperSockets [C#] Hold up to 10K connections.

    Got to say its looking really good.

  9. #8
    Alpha
    Rank
    Member
    Join Date
    Dec 2011
    Posts
    134
    Liked
    39

    Re: SuperSockets [C#] Hold up to 10K connections.

    Quote Originally Posted by -Jordan- View Post
    Got to say its looking really good.
    Thanks :D

  10. #9
    What you looking at?
    Rank
    Subscriber
    Join Date
    Oct 2009
    Location
    London
    Posts
    221
    Liked
    112

    Re: SuperSockets [C#] Hold up to 10K connections.

    I read this thread and truly had a long, ever lasting giggle. Let's hit 300 online before we start worrying about 10,000 online mk?

  11. #10
    aka Illumnia <Guent.nl>
    Rank
    Member +
    Join Date
    Dec 2009
    Location
    The Netherlands
    Posts
    415
    Liked
    224

    Re: SuperSockets [C#] Hold up to 10K connections.

    So, i can now hit up 10.000 players? =D

  12. #11
    # TakeServers Magician
    Rank
    Subscriber
    Join Date
    Oct 2011
    Location
    R:\aGEZONE
    Posts
    321
    Liked
    59

    Re: SuperSockets [C#] Hold up to 10K connections.

    This is awesome, Thanks mate :)

  13. #12
    aka Illumnia <Guent.nl>
    Rank
    Member +
    Join Date
    Dec 2009
    Location
    The Netherlands
    Posts
    415
    Liked
    224

    Re: SuperSockets [C#] Hold up to 10K connections.

    Quote Originally Posted by Muscab View Post
    I read this thread and truly had a long, ever lasting giggle. Let's hit 300 online before we start worrying about 10,000 online mk?
    Actually, agreed.
    This socket will be fine for people that's making their own MMOCC. Having great dedicated servers, and super sockets. But on Habbo Retro's is it almost not reachable.

    Habbo NL - Almost 6k players at a day
    Habbo COM - 10k

    So, how the fuck would a Retro Hotel reach 10k players? i don't know.

  14. #13
    C# | C++
    Rank
    Member +
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    457
    Liked
    88
    Quote Originally Posted by MerijnZ View Post
    So, i can now hit up 10.000 players? =D
    Think about your Mysql Query's etc too!
    Posted via Mobile Device

  15. #14
    Alpha
    Rank
    Member
    Join Date
    Dec 2011
    Posts
    134
    Liked
    39

    Re: SuperSockets [C#] Hold up to 10K connections.

    Quote Originally Posted by Muscab View Post
    I read this thread and truly had a long, ever lasting giggle. Let's hit 300 online before we start worrying about 10,000 online mk?
    We're talking about huge amounts. Matty said up to 10K so i believe an more experienced coder.

    Quote Originally Posted by Emerica View Post
    Think about your Mysql Query's etc too!
    Posted via Mobile Device
    Thats all to you. Some dumbs like: Meth0d created his own Pooling.

    MySQLConnector includes his own pooling thats very better. Using MySQLHelper.

  16. #15
    Works @Duck Hosts (siggy)
    Rank
    Member +
    Join Date
    Dec 2010
    Location
    Australia
    Posts
    1,253
    Liked
    529

    Re: SuperSockets [C#] Hold up to 10K connections.

    It's the actual mysql server that processes all the queries. The emulator tells to server to process these queries. :)

    So if you get alot of lag from running too much queries, it's the mysql server, not the emulator.

 

 
Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •