March 16th, 2011, 04:36 AM
IO model for client handling multiple socket connection
I am working on TCP Client Simulator on C++.Here can simulate 1000 client.each client has some status information which server may require.Server can get the status of a particular client by issuing command with client ID.
Server may issue these command
1."start-stream"-streams the data to server continually.
2."stop stream"-stops the streaming
3. "Status"-asking for status
client respond with 1.streams the data2.stops the streaming 3.send status information to server.
We can't use third party libraries(boost etc) to do this.I need to implement in C++.I came across the Several I/O model like Completion Port,Overlapped I/O etc.I am confused which one will suitable for the client application.
1.I wanted to know what I/O model is suitable for Client to manage these number instance.
2. how can I ensure the state of the each client instance.
3. data structure to maintain the status information of the each client.
Last edited by lok.vikram; March 16th, 2011 at 04:38 AM.
Reason: add more point
March 18th, 2011, 03:38 PM
Re: IO model for client handling multiple socket connection
For simulation of large numbers of clients (thousands), I would tend to use IOCP (I/O completion ports) as the I/O model. Also do some research on the ConnectEx function, which uses overlapped I/O and is thus consistent with the IOCP model (as opposed to WSAConnect or the simple connect() fucntion, which does not use overlapped I/O and thus is inconsistent with the IOCP model). See "ConnectEx Function" at http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx
As for managing state and data structures for each client, that's up to you. You need to manage per-socket state anyway, in order to implement IOCP. Look at implementations of various state machines (sometimes called "finite state machines"). Here's one from Dr. Dobbs Journal: "A Finite State Machine Framework" at http://drdobbs.com/184401784 . It's just one of thousands of examples, so there's no particular preference or recommendation for this one.
Tags for this Thread
Click Here to Expand Forum to Full Width