Object-oriented networking

后端 未结 7 1291
臣服心动
臣服心动 2021-02-05 11:07

I\'ve written a number of networking systems and have a good idea of how networking works. However I always end up having a packet receive function which is a giant switch stat

相关标签:
7条回答
  • 2021-02-05 11:55

    In my experience, table driven parsing is the most efficient method.

    Although std::map is nice, I end up using static tables. The std::map cannot be statically initialized as a constant table. It must be loaded during run-time. Tables (arrays of structures) can be declared as data and initialized at compile time. I have not encountered tables big enough where a linear search was a bottleneck. Usually the table size is small enough that the overhead in a binary search is slower than a linear search.

    For high performance, I'll use the message data as an index into the table.

    0 讨论(0)
提交回复
热议问题