Thread: Protocol Parser?
-
March 21st, 2009, 07:51 PM #1
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?
CreaturesCanon EOS 550D | Tamron 18 - 270mm 1:3.5 - 6.3 | Lensbaby Scout (Soft Focus Optic, Fisheye Optic) | Canon Speedlite 430EX II
-
March 21st, 2009, 08:13 PM #2Not 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
-
March 21st, 2009, 08:37 PM #3
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
CreaturesCanon EOS 550D | Tamron 18 - 270mm 1:3.5 - 6.3 | Lensbaby Scout (Soft Focus Optic, Fisheye Optic) | Canon Speedlite 430EX II
-
March 22nd, 2009, 08:43 AM #4
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
-
what is msxlm 4.0 sp2 parser and sdk
By Felonist in forum General Tech DiscussionReplies: 3Last Post: January 1st, 2009, 11:16 AM -
Protocol Analyzer Help
By taclandude in forum Networking and InternetReplies: 1Last Post: October 14th, 2004, 10:46 AM -
Parser Message???? Error when attempting to...
By jinsta in forum Applications and Operating SystemsReplies: 2Last Post: February 10th, 2004, 02:42 AM -
RoadRunner TAS Protocol
By LiLRiceBoi in forum Networking and InternetReplies: 2Last Post: July 27th, 2002, 02:24 PM -
igmp protocol
By ekl in forum Networking and InternetReplies: 1Last Post: May 13th, 2002, 06:14 PM



LinkBack URL
About LinkBacks




Reply With Quote

It would make for a terrible weapon for the average mass murderer. A more appropriate gift would the The Anarchist Cookbook.
The perfect gift for an aspiring...