HP Rp7410 BSD Sockets Interface Programmer's Guide - Page 172
reqaddr.s_addr
![]() |
View all HP Rp7410 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 172 highlights
Programming Hints Adding a Server Process to the Internet Daemon * BUFFERSIZE - 1 bytes are read so that * room is left at the end of the buffer * for a null character. */ cc = recvfrom(0, buffer, BUFFERSIZE - 1, 0 &clientaddr_in, &addrlen); if ( cc == -1) exit(1); /* Make sure the message received in * null terminated. */ buffer[cc]='\0'; /* Treat the message as a string containing * a hostname. Search for the name * in /etc/hosts. */ hp = gethostbyname (buffer); if (hp == NULL) { /* Name was not found. Return a * special value signifying the error. /* reqaddr.s_addr = ADDRNOTFOUND; } else { /* Copy address of host into the * return buffer. /* reqaddr.s_addr = ((struct in_addr *)(hp->h_addr))->s_addr; } /* send the response back to the requesting client. The * address is sent in network byte order. Note that * all errors are ignored. The client * will retry if it does not receive * the response. */ sendto (0, &reqaddr, sizeof(struct in_addr), 0, &clientaddr_in, addrlen); exit(0); } 172 Chapter 8
![](/manual_guide/products/hewlettpackard-rp5405-bsd-sockets-interface-programmers-guide-5276e7d/172.png)