I am trying to create a thread within a member function of a class with _beginthreadex.
void CapturaDeRed::startCapture() {
unsigned threadID;
HANDLE hTread;
MyData *data=NULL;
data->ifaceName = configCapture();
data->s1 = configSniffer();
//creo el hil y lo asigno
hTread = (HANDLE)_beginthreadex(NULL, 0, &CapturarPacket1, data, 0, &threadID);
}
But the compiler gives me the following error:
Severity Code Description Project File Line Suppression State Error (active) argument of type "unsigned int (__stdcall CaptureDeRed :: *) (void * ap)" is incompatible with parameter of type "_beginthreadex_proc_type"
I put all the code of the implementation:
#include "..\Include\CapturaDeRed.h"
using namespace Tins;
CapturaDeRed::CapturaDeRed()
{
};
CapturaDeRed::~CapturaDeRed()
{
}
unsigned __stdcall CapturaDeRed::CapturarPacket1( void *ap )
{
dta = (MyData*)ap;
Sniffer snfi(dta->ifaceName.name(), dta->s1);
Packet pack(snfi.next_packet());
do {
const TCP & tcp = pack.pdu()->rfind_pdu<TCP>();
TCP tcp1 = TCP(tcp);
} while (true);
_endthreadex(0);
//return 0;
}
void CapturaDeRed::clasificarPacket() {
}
const NetworkInterface CapturaDeRed::configCapture() {
NetworkInterface iface = NetworkInterface::default_interface();
return iface;
}
const SnifferConfiguration CapturaDeRed::configSniffer() {
SnifferConfiguration sc;
sc.set_promisc_mode(true);
sc.set_snap_len(64 *1024);
sc.set_filter("ip and tcp");
return sc;
}
void CapturaDeRed::startCapture() {
unsigned threadID;
HANDLE hTread;
MyData *data=NULL;
data->ifaceName = configCapture();
data->s1 = configSniffer();
//creo el hil y lo asigno
hTread = (HANDLE)_beginthreadex(NULL, 0, &CapturarPacket1, data, 0, &threadID);
}
I appreciate your help and guidance.