+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Go back to sleep Creatures's Avatar
    Join Date
    Jul 2002
    Location
    Switzerland
    Posts
    9,278

    Protocol Parser?

     
    I'm trying to create a server for a game i've been programming for a while, the problem is what is the most efficient way to parse the data and answer correctly?

    I mean a smiple if else is good enough if you dont have more than 20 commands, but imagine a protocol with more than 100? scanning through 100 if else is probably slowing the sever down^^

    any good ideas?

    Creatures
    Canon EOS 550D | Tamron 18 - 270mm 1:3.5 - 6.3 | Lensbaby Scout (Soft Focus Optic, Fisheye Optic) | Canon Speedlite 430EX II

  2. #2
    Not Really a Member
    Join Date
    Oct 2001
    Posts
    27,856
    depends entirely on your language of choice
    each language has their own methods of indexed arrays

    Regardless each language typically has a hash method
    I know in vbs its called a dictionary, I think in Ruby it has the same name.

    basically you dont want to use some crappy bubble sort, so a dictionary is a builtin method to do fast scans for specific data.

    so read protocol command
    lookup command in dictionary
    returns value of requisite function call

  3. #3
    Go back to sleep Creatures's Avatar
    Join Date
    Jul 2002
    Location
    Switzerland
    Posts
    9,278
    the looking up part is where i have my problems, because every method i found so far is as slow as a simple "if else" chain (like switch, hashtable etc.)

    i'm using java btw

    Creatures
    Canon EOS 550D | Tamron 18 - 270mm 1:3.5 - 6.3 | Lensbaby Scout (Soft Focus Optic, Fisheye Optic) | Canon Speedlite 430EX II

  4. #4
    Caveat Emptor Rootstonian's Avatar
    Join Date
    Mar 2005
    Location
    Out of my mind
    Posts
    3,326
    If your data is sorted, a binary search is going to be about your fastest method. Binary tree is nice for unsorted data.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. what is msxlm 4.0 sp2 parser and sdk
    By Felonist in forum General Tech Discussion
    Replies: 3
    Last Post: January 1st, 2009, 11:16 AM
  2. Protocol Analyzer Help
    By taclandude in forum Networking and Internet
    Replies: 1
    Last Post: October 14th, 2004, 10:46 AM
  3. Parser Message???? Error when attempting to...
    By jinsta in forum Applications and Operating Systems
    Replies: 2
    Last Post: February 10th, 2004, 02:42 AM
  4. RoadRunner TAS Protocol
    By LiLRiceBoi in forum Networking and Internet
    Replies: 2
    Last Post: July 27th, 2002, 02:24 PM
  5. igmp protocol
    By ekl in forum Networking and Internet
    Replies: 1
    Last Post: May 13th, 2002, 06:14 PM

Tags for this Thread

Posting Permissions

  • You may post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Recommended Sites: ResellerRatings Store Reviews