SHARE
TWEET

Untitled

a guest Oct 17th, 2019 101 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include<stdio.h>
  3. #include <winsock2.h>
  4.  
  5. using namespace std;
  6.  
  7.  
  8. int main()
  9. {
  10.  
  11. WSADATA wsa;
  12. SOCKET s;
  13.  
  14. if (WSAStartup(MAKEWORD(2,2),&wsa) != 0){
  15. printf("B³¹d: %d",WSAGetLastError());
  16. return 1;
  17. }
  18.  
  19. cout<<"Tworzenie gniazda "<<endl;
  20. if((s = socket(AF_INET , SOCK_STREAM , 0 ))
  21. == INVALID_SOCKET) {
  22. printf("B³¹d tworzenia gniazda: %d",
  23. WSAGetLastError());
  24. }
  25. cout<<"Po³¹czenie: "<< endl;
  26. struct sockaddr_in server;
  27. server.sin_addr.s_addr = inet_addr("172.217.10.110");
  28. server.sin_family = AF_INET;
  29. server.sin_port = htons( 80 );
  30.  
  31. if (connect(s, (struct sockaddr *)&server,
  32. sizeof(server)) < 0) {
  33. puts("B³¹d po³¹czenia");
  34. return 3;}
  35.  
  36.  
  37.  
  38. char *message;
  39. message = "GET / HTTP/1.1\r\n\r\n";
  40. if(send(s, message, strlen(message), 0) < 0){
  41. puts("B³¹d wysy³ania");
  42. return 4;}
  43.  
  44.  
  45.  
  46. char * server_reply= new char[2000];
  47. int recv_size;
  48.  
  49. if((recv_size = recv(s, server_reply, 2000, 0))
  50. == SOCKET_ERROR){
  51. puts("B³¹d odpowiedzi");
  52.  
  53. }
  54. cout<<server_reply<<endl;
  55.  
  56.     return 0;
  57. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top