SHARE
TWEET

Untitled

a guest Apr 19th, 2019 121 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. char* HOST = argv[1];
  2.      char* SERVICE = argv[2];
  3.      char* KEY = argv[3];
  4.  
  5.      int port, n, sfd;
  6.      struct hostent* phe;
  7.      struct sockaddr_in sin;
  8.  
  9.      phe = gethostbyname(HOST);
  10.      sscanf(SERVICE, "%d%n", &port, &n);
  11.  
  12.      sfd = socket(PF_INET, SOCK_STREAM, 0);
  13.  
  14.      sin.sin_family = AF_INET;
  15.      sin.sin_port = htons(port);
  16.      memcpy(&sin.sin_addr, phe->h_addr_list[0], sizeof(sin.sin_addr));
  17.  
  18.      connect(sfd, (struct sockaddr *)&sin, sizeof(sin));
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