connection.c
changeset 84 f59d8a8e786f
parent 77 49e0babccb23
child 111 2247473fd12d
equal deleted inserted replaced
83:220d76d0d672 84:f59d8a8e786f
    27         if ((hs = gethostbyname (ip)) == NULL) {
    27         if ((hs = gethostbyname (ip)) == NULL) {
    28             perror ("[-] Error");
    28             perror ("[-] Error");
    29             return -1;
    29             return -1;
    30         }
    30         }
    31         sock.sin_family = hs->h_addrtype;
    31         sock.sin_family = hs->h_addrtype;
    32         memcpy (&sock.sin_addr.s_addr, hs->h_addr, hs->h_length);
    32         memcpy (&sock.sin_addr.s_addr, hs->h_addr_list[0], hs->h_length);
    33     }
    33     }
    34 
    34 
    35     if ((sockfd = socket (AF_INET, SOCK_STREAM, 0)) < 0) {
    35     if ((sockfd = socket (AF_INET, SOCK_STREAM, 0)) < 0) {
    36         perror ("[-] Error");
    36         perror ("[-] Error");
    37         return -1;
    37         return -1;