daily pastebin goal
74%
SHARE
TWEET

Untitled

a guest Dec 16th, 2018 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <winsock2.h>
  3. #include <ws2tcpip.h>
  4.  
  5. int main()
  6. {
  7. WSADATA wsaData;
  8. sockaddr_in addr;
  9. addr.sin_family = AF_INET;
  10. addr.sin_addr.s_addr = inet_addr("smtp.gmail.com");
  11. addr.sin_port = htons( 587 );
  12.  
  13. //WSA STARTUP
  14. if( WSAStartup( MAKEWORD( 2, 2 ), &wsaData ) )
  15. {
  16.     std::cout<<"Failed to startup wsa.n";
  17.     return 1;
  18. }
  19.  
  20. // GNIAZDO DLA KLIENTA
  21. SOCKET mSocket = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP );
  22. if( mSocket == INVALID_SOCKET )
  23. {
  24.     std::cout<<"Socket error: "<<WSAGetLastError();
  25.     WSACleanup();
  26.     return 1;
  27. }
  28. //LACZENIE Z SERWEREM
  29. int status = connect( mSocket, ( SOCKADDR* ) &addr, sizeof( addr ) );
  30. std::cout<<"Connection status: "<<status;
  31.  
  32.  
  33. return 0;
  34. }
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
 
Top