Posted on 2005-05-14
Last Modified: 2010-04-24
I am creating a server app in C++.NET, I am trying to make it multithreaded. I created a class called multiserver, and it has the method start listening to listen for connections.
void MultiServer::startListening()
      //static variables
      IPHostEntry *ipHost;
      IPAddress *ipA;
      IPEndPoint *ipEP;

    //establish endpoint
      ipHost = Dns::Resolve(Dns::GetHostName());
      ipA = ipHost->AddressList[0];
      ipEP = new IPEndPoint(ipA, 11000);

      //start blocking
      tListen = new TcpListener(ipEP);

      //loop to start connections
                  clientSoc = tListen->AcceptSocket();
                  clService = new Thread(new ThreadStart(this, servClient));
            }//end try
            catch(Exception *e)
                  MessageBox::Show(e->ToString(), S"Error", MessageBoxButtons::OK, MessageBoxIcon::Error);
            }//end catch
      }//end while
}//end start listening

On the main Form1 for the app I have another thread start
public __gc class Form1 : public System::Windows::Forms::Form

                  //thread directing
                  MultiServer *ms;
                  clientList = new ArrayList();
                  processor = new Thread(new ThreadStart(&ms, ms->startListening));

The problem I am have is this:
error C3754: 'void MultiServer::startListening(void)': cannot be called through a variable of type 'MultiServer __gc ** '
Can anyone help?
Question by:fsharer
    LVL 6

    Accepted Solution


    Author Comment

    Tried it, by creating a new class of listening giving it the start listening function, and inheriting for my other class multiserver, then having it create a new class of listening and refrencing it in the trhead but gives the same error.

    #pragma once

    #include "MultiServer.h"

    public __gc class Listening : public MultiServer
    void startListening();      //constructor

    };//end class listening

    MultiServer *ms = new Listening;
    clientList = new ArrayList();
    processor = new Thread(new ThreadStart(ms, &Listening::startListening)); <--Line I am getting error C3754
    LVL 6

    Expert Comment

    Is it giving the same message, or is the type in the error message different?

    Author Comment

    Sorry here is the new error:
     error C3754: 'void Listening::startListening(void)': cannot be called through a variable of type 'MultiServer __gc *'

    Its' a little different from the one above, but doesnt it mean the same
    LVL 6

    Expert Comment

    I seem to remember something about a 'virtual' keyword.  Try marking the function as virtual.  I'm really starting to shoot from the hip now, though.

    Author Comment

    Its ok, it didnt work, I think I just need to hit the books harder. But I will still give you the points for helping me out.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
    In Easy String Encryption Using CryptoAPI in C++ ( I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    This video discusses moving either the default database or any database to a new volume.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now