{"bytes":[116,101,115,116],"subtype":null}
.static Task ProxyRun<T1,T2> (Action<T1> action, T1 arg1,) {
return Task.Run(() => action(arg1));
}
static Task ProxyRun<T1,T2> (Action<T1,T2> action, T1 arg1, T2 arg2) {
return Task.Run(() => action(arg1, arg2));
}
static Task<TResult> ProxyRun<T1,TResult> (Func<T1,T2,TResult> action, T1 arg1,) {
return Task<TResult>.Run(() => action(arg1, arg2));
}
static Task<TResult> ProxyRun<T1,T2,TResult> (Func<T1,T2,TResult> action, T1 arg1, T2 arg2) {
return Task<TResult>.Run(() => action(arg1, arg2));
}
static Task StartNew<T1,T2> (this TaskFactory taskFactory, Action<T1,T2> action, T1 arg1, T2 arg2) {
return taskFactory.StartNew(() => action(arg1, arg2));
}
int main() {
const char* endl = "\r\n";
WSADATA wsa;
std::string domin;
int status;
std::string write_data;
struct addrinfo hints = { 0 }, * res, * p;
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
SetConsoleCP(GetACP());
SetConsoleOutputCP(GetACP());
if (status = WSAStartup(MAKEWORD(2, 2), &wsa) != 0) {
std::cout << "Error: of WSAStatus: " << gai_strerror(status) << std::endl;
return status;
}
std::cout << "Enter domin: " << std::endl;
std::getline(std::cin, domin);
if (status = getaddrinfo(domin.c_str(), "80", &hints, &res) != 0) {
std::cout << ("Error: of getaddrinfo", gai_strerror(status));
return status;
};
{
std::ostringstream ws;
ws << "GET / HTTP/1.1" << endl;
ws << "Host: " << domin << endl;
ws << "Accept: text/html, text/*" << endl;
ws << "Connection: close" << endl;
ws << endl;
write_data = ws.str();
}
std::cout << write_data;
char ipstr[1024];
int s = INVALID_SOCKET;
char bufrecv[2048];
for (p = res; p != NULL; p = p->ai_next) {
const char* ipver;
void* addr;
if (p->ai_family == AF_INET) {
struct sockaddr_in* ipv4 = (struct sockaddr_in*)p->ai_addr;
addr = &(ipv4->sin_addr);
ipver = "IPv4: ";
}
else {
struct sockaddr_in6* ipv6 = (struct sockaddr_in6*)p->ai_addr;
addr = &(ipv6->sin6_addr);
ipver = "IPv6: ";
}
inet_ntop(p->ai_family, addr, ipstr, sizeof(ipstr));
std::cout << "addres: " << ipver << ipstr << std::endl;
if (s != INVALID_SOCKET) {
shutdown(s, SD_BOTH);
closesocket(s);
}
if (((s = socket(p->ai_family, p->ai_socktype, p->ai_protocol))) == INVALID_SOCKET) {
std::cout << "error of socket: " << WSAGetLastError() << std::endl;
continue;
}
if ((connect(s, p->ai_addr, p->ai_addrlen)) == SOCKET_ERROR) {
std::cout << "Error of connect: " << WSAGetLastError() << std::endl;
continue;
}
bool success = true;
int writed = 0;
for (size_t i = 0, data_len = write_data.length(); i < data_len; i += writed) {
writed = send(s, write_data.c_str() + i, (int)min(data_len - i, INT_MAX), 0);
if (writed == SOCKET_ERROR) {
std::cout << "Error of send: " << WSAGetLastError() << std::endl;
success = false;
break;
}
}
if (success) {
int readed;
while ((readed = recv(s, bufrecv, sizeof(bufrecv), 0)) != SOCKET_ERROR && readed != 0) {
std::cout << std::string(bufrecv, readed);
}
if (readed == SOCKET_ERROR) {
std::cout << " recv " << WSAGetLastError() << std::endl;
}
break;
}
}
if (s != INVALID_SOCKET)
{
shutdown(s, SD_BOTH);
closesocket(s);
}
freeaddrinfo(res);
WSACleanup();
system("pause");
return 0;
}
enable_post_data_reading = Off
apt-get download $(apt-cache depends --recurse --recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances kde-plasma-desktop | grep "^\w" | sort -u)
var tmp_leader = leader;
Console.Write(tmp_leader == null ? "." : tmp_leader.id.ToString());
#pragma comment (lib,"Ws2_32.lib")
#include <winsock2.h>
#include <WS2tcpip.h>
#include <Windows.h>
#include <iostream>
#include <string>
int main() {
WSADATA wsa;
std::string domain;
int status;
struct addrinfo hints = { 0 }, * res, * p;
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
// ошибки выводятся в ANSI кодировке, а консоль по умолчанию в OEM
SetConsoleCP(GetACP());
SetConsoleOutputCP(GetACP());
// На Windows необходима инициализация сетевой библиотеки
if (status = WSAStartup(MAKEWORD(2, 2), &wsa) != 0) {
std::cout << "Error: of getaddrinfo: " << get_error_message(status) << std::endl;
// принято возвращать причину ошибки, а не только сам факт
return status;
}
std::cout << ("Enter domain: ");
// даже доменные имена могут иметь длину 256 символов
// пользователь же может вообще ввести сколько ему угодно
std::getline(std::cin, domain);
if (status = getaddrinfo(domain.c_str(), "80", &hints, &res) != 0) {
std::cout << "Error: of getaddrinfo: " << get_error_message(status) << std::endl;
return status;
};
char ipstr[INET6_ADDRSTRLEN];
for (p = res; p != NULL; p = p->ai_next) {
/*const char* ipver;*/
void* addr;
if (p->ai_family == AF_INET) {
struct sockaddr_in* ipv4 = (struct sockaddr_in*)p->ai_addr;
addr = &(ipv4->sin_addr);
/*ipver = "IPv4:";*/
}
else {
struct sockaddr_in6* ipv6 = (struct sockaddr_in6*)p->ai_addr;
addr = &(ipv6->sin6_addr);
/*ipver = "IPv6:";*/
}
inet_ntop(p->ai_family, addr, ipstr, sizeof(ipstr));
std::cout << "addres: " << ipstr << std::endl;
};
freeaddrinfo(res);
system("pause");
// деструктор сетевой библиотеки
WSACleanup();
return 0;
}
// xyz.h
class xyz
{
private:
int abc;
public:
PROJECT2_API int printing_int();
};
//xyz.cpp
PROJECT2_API int hyz::printing_int() { // return 5
return abc;
}
void printing(char* pChar) {
char a[] = "Example String";
strcpy_s(pChar, strlen(a) + 1, a);
}
int main() {
char[4] buff = {0};
printing(buff);
printf("%s\n", buff);
}