Wednesday, 15 May 2013

sockets - Can a single process perform concurrent non-blocking IO over the same port? -



sockets - Can a single process perform concurrent non-blocking IO over the same port? -

i trying understand how concurrency works @ scheme level.

backstory

i have application , datastore. datastore can have several processes running , can handle multiple requests concurrently. datastore accepts communication on single tcp port using protocol in format <msg length> <operation code> <operation data>

the existing application code blocks on datastore io. spin several threads accomplish concurrency, still each thread block on io. have single thread non-blocking io libraries using them should require me socket programming.

question

how single-process connection pool single non-blocking port work? understand port maintains sort of mapping can send response right place when response ready. read uses requestor's ip key. if multiple requests same port occur same process, wouldn't messages mixed / intermingled?

or, each connection assigned unique key, create connection pool need store list of connection objects , guaranteed never interact each other?

edit: don't know why said tcp, , half content of question unnecessary ... embarrassed. ought delete it, actually. voted.

the datastore accepts communication on single tcp port

the result of accept() new full-duplex socket can read , written concurrently , independently of other sockets in process. fact local port shared irrelevant. tcp ports aren't physical objects, numbers.

non-blocking mode , info stores have nil it.

sockets

No comments:

Post a Comment