TCP/IP Programming Manual
AF_INET6 Server Stub Program
This example shows a sample server program that you can build, compile, and run on your system.
The program receives requests from and sends responses to client programs on other systems.
/*
 * AF_INET6 Server Stub Routine
 * *****************************************************************
 * * *
 * * Copyright (c) Hewlett-Packard Company, 2003 *
 * * *
 * * The software contained on this media is proprietary to *
 * * and embodies the confidential technology of Hewlett *
 * * Packard Corporation. Possession, use, duplication or *
 * * dissemination of the software and media is authorized only *
 * * pursuant to a valid written license from Hewlett Packard *
 * * Corporation. *
 * * *
 * * RESTRICTED RIGHTS LEGEND Use, duplication, or disclosure *
 * * by the U.S. Government is subject to restrictions as set *
 * * forth in Subparagraph (c)(1)(ii) of DFARS 252.227-7013, *
 * * or in FAR 52.227-19, as applicable. *
 * * *
 * *****************************************************************
 */
#include <systypes.h>
#include <socket.h>
#include <errno.h>
#include <in.h>
#include <in6.h>
#include <netdb.h>
#include <string.h>
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include <inet.h>
#include <nameser.h>
#include <cextdecs(FILE_CLOSE_)>
#define SERVER_PORT 7639
#define CLIENT_PORT 7739
#define MAXBUFSIZE 4096
int main (
 int argc,
 char **argv )
{
 int s;
 char databuf[MAXBUFSIZE];
 int new_s;
 int dcount;
 char addrbuf[INET6_ADDRSTRLEN];
 char node[MAXDNAME];
 char port[MAXDNAME];
 int ni;
 int clientaddrlen;
 /* Declare the sockaddr_in6 structure named serveraddr. The use 
 of this type of structure is dictated by the communication domain
 of the socket (AF_INET6), which implies communication using the IPv6
 protocol. */
 struct sockaddr_in6 serveraddr;
238 Sample Programs










