Использую libcurl, нужно на сайте один постит сообщение в тег
<p>message=#%some_number%,%some_message%</p>
другой читает и наоборот если номер сообщения уже есть в textedit'e то не добавляется и так каждую секунду проверяет сайт юкоз
вот принимает данные
size_t write_data(char *ptr, size_t size, size_t nmemb, FILE* data)
{
return fwrite(ptr, size, nmemb, data);
}
void__ Math::SetRotate()
{
if(!Drum_->GetAllRoll()&&GetCredits()>=GetTotalBet()&&GetWin_()==0)
{
#if netsupport==1
/*
Con_->SetBuf("Give Me Next Datagramm",0);
Con_->Snd(0);
Con_->ClearBuf(0);
Con_->Recv(0);
Drum_->SetBuffer(Con_->GetBuf(0));
Con_->ClearBuf(0);
*/
const std::string header_filename = "head.txt";
const std::string body_filename = "body.html";
#ifdef _WINDOWS_2
FILE *header_file;
fopen_s(&header_file, header_filename.c_str(), "w");
#else
FILE *header_file = fopen(header_filename.c_str(), "w");
#endif
//if (header_file == NULL)
// return -1;
#ifdef _WINDOWS_2
FILE *body_file;
fopen_s(&body_file, body_filename.c_str(), "w");
#else
FILE *body_file = fopen(body_filename.c_str(), "w");
#endif
//if (body_file == NULL)
// return -1;
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if (curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://getlucky2.ucoz.net");
// example.com is redirected, so we tell libcurl to follow redirection
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; rv:16.0) Gecko/20100101 Firefox/16.0");
curl_easy_setopt(curl, CURLOPT_AUTOREFERER, 1);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, body_file);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
// сохраняем заголовок
curl_easy_setopt(curl, CURLOPT_WRITEHEADER, header_file);
//USING CURLOPT NOBODY
//curl_easy_setopt(curl, CURLOPT_NOBODY, 1);
// Perform the request, res will get the return code
res = curl_easy_perform(curl);
// Check for errors
//if (res != CURLE_OK)
// std::cout << "curl_easy_perform() failed: %s\n" << curl_easy_strerror(res) << std::endl;
// always cleanup
curl_easy_cleanup(curl);
}
fclose(body_file);
fclose(header_file);
#ifdef _WINDOWS_2
fopen_s(&body_file, body_filename.c_str(), "r");
#else
body_file = fopen(body_filename.c_str(), "r");
#endif
//if (body_file == NULL)
// return -1;
char *str = new char[64];
std::string stroke = "";
while (!feof(body_file))
{
fgets(str, 64, body_file);
if (strstr(str, "random1="))
stroke += str;
}
fclose(body_file);
delete[] str;
int j = 0;
while (stroke[j++] != '=')
;
std::string *strmas = new std::string[14];
for (int i = 0; i < 14; i++)
{
while (stroke[j] != '|')
strmas[i] += stroke[j++];
strmas[i] += stroke[j++];
//std::cout << strmas[i] << std::endl;
}
std::string totalstr = "";
srand(time(0));
int max_ = 14, min_ = 0;
for (int i = 0; i<30; i++)
totalstr += strmas[((int__)((float__)rand() / RAND_MAX*(max_ - min_) + min_))];
//std::cout << totalstr << std::endl;
Drum_->SetBuffer((char__*)totalstr.c_str()/*"4|5|6|7|8|9|10|11|12|13|14|15|16|17|4|5|6|7|8|9|10|11|12|13|14|15|16|17|4|5"*/);
#endif
Drum_->Start();
for(int__ i=0;i<GetCountDrums();i++)
{
if(!i)
fps = 0;
time_[i]=clock();
Drum_->Set(1+Drum_->Get(i),i);
StartAcceleration(i);
Drum_->SetRoll(true,i);
}
}
}