Может ли кто-нибудь помочь мне понять, почему мой ответ не выдает ответ json с сервера stratum, единственный ответ, который он мне дает, - это успех 200k.Но для получения биткойнов с сервера мне нужен ответ json.
WSADATA wsa;
SOCKET s, ss;
struct sockaddr_in server;
char *message, *message2, *message3, *message4,*message5, *message6, *message7, *message8, *message9, *message10, *message11, *message12,*message13, *message14, *message15, *message16;
char *message50, *server_reply[2000];
int recv_size, i;
time_t t = time(0);
char sentence[1000];
FILE *fptr;
///Initialising Winsock
printf("\nInitialising Winsock....");
while(WSAStartup(MAKEWORD(2,2),&wsa) !=0)
{
printf("Failed. Error Code : %d", WSAGetLastError());
return 1;
}
printf("\nInitialised....");
///Create Socket Created
while((s = socket(AF_INET, SOCK_STREAM, 0 )) == INVALID_SOCKET)
{
return 0;
}
printf("\nSocket Created.....\n");
memset( &server, 0, sizeof(server));
/*server.sin_addr.s_addr = inet_addr("98.138.219.232");*/
server.sin_addr.s_addr = inet_addr("3.248.184.224");
//server.sin_addr.s_addr = inet_addr("192.162.72.233");
//server.sin_addr.s_addr = inet_addr("172.217.3.164");
//server.sin_addr.s_addr = inet_addr("72.30.35.9");
server.sin_family = AF_INET;
server.sin_port = htons ( 3333 );
///connect to server
while(connect(s, ( struct sockaddr * )&server, sizeof(server))&&0)
{
puts("\nconnect error");
return 1;
}
puts("\nConnected.....");
///Send Some Data
message = "GET / HTTP/1.1\r\n\r\n /*Host:%s\r\n *\r\n\r\n /*User-Agent: *\r\n\r\n /*Connection: keep-alive* \r\n\r\n /*Access-Control-Allow-Origin: *\r\n\r\n /*Allow: *GET *\r\n\r\n /*Front-End-Https: *on *\r\n\r\n /*Access-Control-Max-Age: *\r\n\r\n /Public-Key-Pins: max-age=2592000; pin-sha256=60e9520091710f78b694c3b638a088612197f059377b34bf1f81263e493b09b0; *\r\n\r\n /Cache-Control: max-age=3600 *\r\n\r\n /Transfer-Encoding: chunked *\r\n\r\n /Set-Cookie: UserID=AndrayCarlMcWilliams592389560; Max-Age=3600; Version=1 *\r\n\r\n /Save-Data: on *\r\n\r\n /DNT: 0 *\r\n\r\n /A-IM: feed *\r\n\r\n /UTC: %s, asctime(gmtime(&t)) /Content-Type: application/json\r\n\r\n /Accept: application/json\r\n\r\n ";
///Send Some Data 2
message2 = "GET / HTTP/1.1\r\n\r\n";
message3 = "GET / *User-Agent: *\r\n\r\n";
message4 = "GET / HTTP/1.1\r\n\r\n";
message5 = "GET / *Connection: keep-alive* \r\n\r\n";
message6 = "GET / HTTP/1.1\r\n\r\n";
message7 = "GET / *Access-Control-Allow-Origin: *\r\n\r\n";
message8 = "GET / HTTP/1.1\r\n\r\n";
message9 = "GET / *Allow: *GET *\r\n\r\n";
message10 = "{\"id\":1,\"method\":\"mining.subscribe\",\"params\":[]}";
message11 = "GET / *Front-End-Https: *on *\r\n\r\n";
message12 = "GET / HTTP/1.1\r\n\r\n";
message13 = "GET / User-Agent: *\r\n\r\n";
message14 = "GET / HTTP/1.1\r\n\r\n";
message15 = "GET / User-Agent: *\r\n\r\n";
message16 = "GET / HTTP/1.1\r\n\r\n";
///Send Some Data (ing)
while( send(s, message, strlen(message), 0)&&0)
{
puts("\nSend Failed");
return 1;
}
puts("\nData Send");
///Receive a reply from server
while((recv_size = recv(s, server_reply, 2000, 0)) == SOCKET_ERROR)
{
puts("\nrecv failed");
}
puts("\nReply Received");
///add a NULL terminating character to make it a proper string before printing
server_reply[recv_size] = '\0•';
//puts(server_reply);
//printf(server_reply);
///add Dray and add header field with priors server reply response (ching 0.01)
while( send(s, server_reply, strlen(server_reply), 0)&&0)
{
puts("\nSend Failed2");
return 1;
}
puts("\nData Send2");
while((recv_size = recv(s, server_reply, 2000, 0)) == SOCKET_ERROR)
{
puts("\nrecv failed");
}
puts("\nReply Received");
///Add a NULL terminating character to make it a proper string before printing
server_reply[recv_size] = '\0';
puts(server_reply);
printf(server_reply);
Мой код может нуждаться в дополнительной поддержке, поскольку он не отвечает ответом json.