c# - Suggestions for developing a TCP/IP based message client -


i've got server side protocol controls telephony system, i've implemented client library communicates in production now, there problems system have @ moment, considering re-writing it.

my client library written in java thinking of re-writing in both c# , java allow different clients have access same end.

the messages start keyword have number of bytes of meta data , data. messages terminated end of message character.

communication duplex between client , server taking form of request client provokes several responses server, can notifications. messages marked being on of:

c: command

p: pending (server still handling request)

d: data data response

r: response

b: busy (server busy handle response @ moment)

n: notification

my current architecture has each message being parsed , thread spawned handle it, i'm finding of notifications processed out of order causing me trouble have handled in same order arrive.

the duplex messages tend take following message format: client -> server: command server -> client: pending (optional) server -> client: data (optional) server -> client: response (2nd entry in message data denotes whether error or not)

i've been using protocol on year , i've never seen busy message doesn't mean don't happen.

the server can send notifications client, , there few response messages auto triggered events on server sent without corresponding command being issued.

some notification messages arrive part of sequence of messages, related example:

notificationname m00001 notificationname m00001 notificationname m00000

the string m0000x means either there more data come or end of messages.

at present tcp client dumb spawns thread notifies event on subscriber message has been received, event specific message keyword , type of message (so data,responses , notifications handled separately) works data , response messages, falls on notification messages seem arrive in rapid sequence , race condition seems cause message end processed before ones have data processed, leading lost message data.

given badly written description of how system works how go writing client side transport code?

the meta data not have message number, , have not control on underlying protocol it's provided vendor.

i have 1 thread per client parsing , processing. way processing in order sent/arrives.

as have stated, tasks cannot perform in parallel safely. performing parsing , processing in different threads add overhead might save.

if processing relatively simple , doesn't depend on external systems, single thread should able handle 1k 20k messages per second.

is there other issues want fix?


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -