Socket servers, SocketAsyncEventArgs and concurrent connections in .Net -


i've been writing socket server based around 1 on codeproject derives original microsoft example.

in both cases, inbound message returned sender using same socketasynceventargs. in case, need send inbound message off further async processing prior replying client.

the problem returning response may try use same socketasynceventargs @ same time further message client. when happens exception:

"an asynchronous socket operation in progress using socketasynceventargs instance"

so, (i believe) need separate pool of socketasynceventargs messages going out. understandable far.

my problem i'm not sure how create outbound socketasynceventargs relates closely inbound one.

how of inbound 1 can reuse? e.g. if point @ same acceptsocket, there trouble while messages travel in both directions simultaneously?

does have example code of how derive outbound socketasynceventargs inbound one? or missing point?

these socketasynceventargs objects, can use them please. serve you. , socket , buffer use.

so, having codeproject article example, makes sense reuse same saea instance sendasync() right after whole receive (possibly made of several receiveasync() calls) has completed. author states protocol is: each 1 of parties involved send , receive in turns.

in case, simplest release saea instance pool after whole receive completes. then, later on, after finished message processing, can issue brand new send operation using freshly popped pool socketasynceventargs object.

another option keep passing saea used receive operation callback callback during asynchronous processing, , use sending processed message.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -