CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2008

    Smile 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

  2. #2
    Join Date
    Nov 2002

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.