Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 290
  • Last Modified:

Threads

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);
      tListen->Start();

      //loop to start connections
      while(true)
      {
            try
            {
                  clientSoc = tListen->AcceptSocket();
                  clService = new Thread(new ThreadStart(this, servClient));
                  clService->Start();
            }//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
      {      
      public:
            Form1(void)
            {
                  InitializeComponent();

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

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?
0
fsharer
Asked:
fsharer
  • 3
  • 3
1 Solution
 
guitaristxCommented:
0
 
fsharerAuthor Commented:
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
{
public:
      
void startListening();      //constructor
      

protected:
      
};//end class listening


MultiServer *ms = new Listening;
clientList = new ArrayList();
processor = new Thread(new ThreadStart(ms, &Listening::startListening)); <--Line I am getting error C3754
0
 
guitaristxCommented:
Is it giving the same message, or is the type in the error message different?
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
fsharerAuthor Commented:
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
0
 
guitaristxCommented:
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.
0
 
fsharerAuthor Commented:
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.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now