5 * \defgroup Hostlookup Examine a socket and determine the name/address of the originating host.
12 * \brief get a hostname
14 * \param tbuf the returnbuffer
15 * \param client_socket the sock fd where the client is connected
17 void locate_host(char *tbuf, int client_socket)
19 struct sockaddr_in cs;
26 if (getpeername(client_socket, (struct sockaddr *) &cs, &len) < 0) {
27 strcpy(tbuf, "<unknown>");
30 if ((ch = gethostbyaddr((char *) &cs.sin_addr, sizeof(cs.sin_addr),
32 i = (char *) &cs.sin_addr;
37 sprintf(tbuf, "%d.%d.%d.%d", a1, a2, a3, a4);
40 safestrncpy(tbuf, ch->h_name, 64);