Forming A Socket Address Structure After we look up the address, we need to form a 'sockaddr_in' structure containing the data. The exact contents of this structure is system specific, so it is manipulated carefully in a rather portable way, like this: #include /* memset, memcpy */ #include /* Internet address structures */ struct sockaddr_in* sa; /* Internet address struct. */ /* first clear out the struct, to avoid garbage */ memset(&sa, 0, sizeof(sa)); /* Using Internet address family */ sa.sin_family = AF_INET; /* copy port number in network byte order */ sa.sin_port = htons(13); /* copy IP address into address struct */ memcpy(&sa.sin_addr.s_addr, hen->h_addr_list[0], hen->h_length);