class design question

Discussion in 'C++' started by Angus, Jul 16, 2007.

  1. Angus

    Angus Guest

    Hello

    I have some networking classes. I have a base class - CBasicSocket,
    then a server socket which is CServerSocket : public CBasicSocket and
    a client socket which is CClientSocket : public CBasicSocket.

    The client class gets notified via a virtual function when the socket
    is dosconnected. The server class gets notified if the server socket
    is disconnected - ie the server shuts down.

    My server class holds a collection of clients. When the server class
    gets a connection from a new client, this collection gets
    incremented. But I need to decrement the collection when a client
    disconnects. But my CServerSocket class doesn't get notified about
    this event. CClientSocket does. So does my CServerSocket class need
    to contain a CClientSocket class? How do I set this up so that my
    CServerSocket class gets the notification that a client has
    disconnected?
     
    Angus, Jul 16, 2007
    #1
    1. Advertising

  2. Angus

    Jim Langston Guest

    "Angus" <> wrote in message
    news:...
    > Hello
    >
    > I have some networking classes. I have a base class - CBasicSocket,
    > then a server socket which is CServerSocket : public CBasicSocket and
    > a client socket which is CClientSocket : public CBasicSocket.
    >
    > The client class gets notified via a virtual function when the socket
    > is dosconnected. The server class gets notified if the server socket
    > is disconnected - ie the server shuts down.
    >
    > My server class holds a collection of clients. When the server class
    > gets a connection from a new client, this collection gets
    > incremented. But I need to decrement the collection when a client
    > disconnects. But my CServerSocket class doesn't get notified about
    > this event. CClientSocket does. So does my CServerSocket class need
    > to contain a CClientSocket class? How do I set this up so that my
    > CServerSocket class gets the notification that a client has
    > disconnected?


    Are you using both CServerSocket and CClientSocket in the same program at
    the same time? Can an instance of your program be both a Client and a
    Server?

    Your server class should know when a client disconnects, that's a part of
    socket programming. Even if it's time out errors. If you have a
    CServerSocket connected to a CClientSocket, that CClientSocket would be on a
    different machine, wouldn't it?

    Now, unless your CBasicSocket gets the disconnect notice and the
    CServerSocket doesn't check or get informed, then have your CBasicSocket let
    the CServerSocket know. It depends on your design.
     
    Jim Langston, Jul 16, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dave
    Replies:
    5
    Views:
    599
    William Brogden
    Jul 17, 2004
  2. E11
    Replies:
    1
    Views:
    4,801
    Thomas Weidenfeller
    Oct 12, 2005
  3. christopher diggins
    Replies:
    16
    Views:
    761
    Pete Becker
    May 4, 2005
  4. John_Woo

    class design vs. db design

    John_Woo, Dec 19, 2006, in forum: Java
    Replies:
    2
    Views:
    333
    John_Woo
    Dec 19, 2006
  5. Bartholomew Simpson

    class design/ design pattern question

    Bartholomew Simpson, Jun 12, 2007, in forum: C++
    Replies:
    2
    Views:
    453
    Daniel T.
    Jun 12, 2007
Loading...

Share This Page