SHARE
TWEET

TCP_CLIENT_01

skindervik Jun 30th, 2020 832 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2. #include<WS2tcpip.h>
  3. #include<thread>
  4. #include<sstream>
  5. #include<vector>
  6. #pragma comment (lib, "Ws2_32.lib")
  7. int main() {
  8.     WSADATA some_kind_of_data;
  9.     WSAStartup(MAKEWORD(2, 2), &some_kind_of_data);
  10.  
  11.     //CREATE CONNECTION SOCKET
  12.     sockaddr_in connect_adress;
  13.     connect_adress.sin_family = AF_INET;
  14.     connect_adress.sin_port = htons(666);
  15.     inet_pton(AF_INET, "127.0.0.1" , &connect_adress.sin_addr);
  16.  
  17.     SOCKET connection_socket = socket(AF_INET, SOCK_STREAM, 0);
  18.  
  19.     connect(connection_socket, (sockaddr*)&connect_adress, sizeof(connect_adress));
  20.  
  21.     std::string message = "wow, look at me code";
  22.  
  23.     send(connection_socket, message.c_str(), message.size()+1, 0);
  24.  
  25.     //CLEAN UP
  26.     closesocket(connection_socket);
  27.     WSACleanup();
  28. }
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