Results 1 to 9 of 9

Thread: Winsock, Multithreading

  1. #1

    Thread Starter
    Registered User
    Join Date
    Mar 2004
    Location
    in a dirthole
    Posts
    117

    Winsock, Multithreading

    ok i had looked at previous posts on Winsock and Multithreading and im wondering if anyone will kindly restart this thread on explaining how i would go about making a MUD text game

    the server for this game will need to use winsock allowing TONS of connections and sending commands at the same time... what i got set up right now is that if one person sends a command at the same time as another it shuts off the one connection and goes to the newest one until a command is resent by the one that got shut off, so that's when i looked at the other post winsock and mulithreading and it confused the hell outa me so can anyone please help me out with this i'd REALLY appreciate it,

    what confused me the most was all the terms and questions that i dont understand, so i can't follow along

  2. #2
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    703
    Don't close connections unless the client wants to disconnect. It's better to provide uninterrupted service to some number of clients than randomly disconnect clients in order to process extra ones.

    It all depends on the numbers of clients. TBH, if you're talking about a LOT of clients (i.e. several hundred), I'd really recommend looking into not using VB; for high-client situations you probably want to be using I/O completion ports and overlapped I/O, which isn't very feasible with VB.

    I'm not sure what you want to know about multithreading with winsock, could you explain?
    an ending

  3. #3

    Thread Starter
    Registered User
    Join Date
    Mar 2004
    Location
    in a dirthole
    Posts
    117
    follow this link if you want more about the winsock and multithreading
    http://www.vbforums.com/showthread.p...hreadid=267548

    i had already went there and previous to me wanting to do this i had read wokawidgets thread on threading in general and im confused by it all, and yes im looking to have hundreds of people connectiong to this server.

  4. #4
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    703
    From a quick glance, it all looks a bit inefficient for a game. Looks like huge amounts of overhead really. High-client count and/or high-throughput servers aren't VB's strongpoint to be honest; when the language works against you, you're better off using a different language.
    an ending

  5. #5

    Thread Starter
    Registered User
    Join Date
    Mar 2004
    Location
    in a dirthole
    Posts
    117
    but i dont know any other language and this si something i want done now, im kinda an impatient kinda guy lol, can anyone else varify what was previously said? becausei have high hopes for making this game
    Last edited by krpto; Mar 30th, 2004 at 06:07 PM.

  6. #6
    Hyperactive Member
    Join Date
    Jan 2002
    Location
    The Netherlands
    Posts
    425
    I've created a server once, also for a MUD like game. It was fully text based and the client was Flash. However, I've also created my own 'test' client because the Flash Client was created by someone other than me, so I needed something to test with.

    What I experienced was that winsock tends to 'forget' information send to it by another (VB) client using Winsock. When two users where on at the same time, some data just got 'lost'. This problem was not noticed with any of the Flash clients. Later I found something on this board telling me that this was a Winsock bug, but it's still there unfortunately.

    The advantage of using Flash is that it's online and you can make it more graphical

    Here you can find a Class version of Winsock: http://www.vbforums.com/showthread.p...=Winsock+class
    I didn't use this before, so I don't know if it works OK, but you could try anyway Maybe this will solve the 'forgetting' problem. You can even create an ActiveX EXE for multithreading and place the Winsock Class in there...

    Good luck
    "Experience is something you don't get until just after you need it."

  7. #7
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    703
    FYI, multithreading is not the cure-all solution to creating high performance networked apps. Worry about the I/O model you want to use, then think how you need to implement it.

    Of course if you use VB, the I/O model choice is rather limited (blocking, non-blocking, non-blocking with windows message notification) and the best techniques aren't feasible to implement in VB.

    Disclaimer in case VB purists want to flame ( ): VB will work just fine for a low-client count server.
    an ending

  8. #8
    Fanatic Member VBAhack's Avatar
    Join Date
    Dec 2004
    Location
    Sector 000
    Posts
    617

    Re: Winsock, Multithreading

    Quote Originally Posted by azteched
    FYI, multithreading is not the cure-all solution to creating high performance networked apps. Worry about the I/O model you want to use, then think how you need to implement it.

    Of course if you use VB, the I/O model choice is rather limited (blocking, non-blocking, non-blocking with windows message notification) and the best techniques aren't feasible to implement in VB.

    Disclaimer in case VB purists want to flame ( ): VB will work just fine for a low-client count server.
    Can you elaborate as to why the best techniques aren't feasible in VB? Also, I've seen the following terms in my searches:

    Multithreading
    Asynchronous I/O
    Overlapped I/O
    I/O Completion sockets

    Are all of these the same? Thanks for any replies/clarifications.

    VBAhack

  9. #9
    Fanatic Member Comintern's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln, NE
    Posts
    826

    Re: Winsock, Multithreading

    I'm actually in the process of doing the same thing you are. In my case, I'm translating CircleMud to VB for some coding practice. I think you'll be fine using VB for your codebase as long as you do as much through the APIs as you possibly can. This means:

    Step One. Read about Berkeley sockets and the Winsock API.
    Step Two. Resist the urge to use a Winsock control.
    Step Three. Read about Berkeley sockets and the Winsock API again.
    Step Four. Try to implement your socket routines.
    Step Five. Read about Berkeley sockets and the Winsock API again.
    Setp Six. Repeat step four.

    Then you should be able to get it off the ground. Personally, I'm at step four . Couple of things to keep in mind. First, you probably don't want to make your server event driven because this would prevent you from keeping all of your connections acting in the same timespace. Second, you probably don't want to multi-thread anything except for your administration functions, for the same reason. I'm doing mine as a activeX dll and exposing functionality to put an administrative interface on top of it. Finally, you need to use string handling functions that are faster than those that VB gives you, as this will be the biggest time-sink for you. I found a string class somewhere (might have been on the forums here-will check when I'm on my other machine) that smokes compared to VB. Some stuff to get you started:

    http://www.vbip.com/winsock-api/default.asp

    Attached is the current state of my game-loop code. I've moved to implementing the object structures and can't test this until I'm done, so it might not work at all as written now. Note also that I'm writing VB directly over the C source, so it isn't organized to my taste yet, but you will get more out of it if you can read C.

    BTW, if you use any of the code in the example, you will need to comply with the CircleMud license, which can be found here:

    http://www.circlemud.org/license.html
    Attached Files Attached Files
    Last edited by Comintern; Mar 3rd, 2005 at 09:46 AM. Reason: Add license information.

Posting Permissions

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



Click Here to Expand Forum to Full Width