TCP/IP Programming Manual
IPv4 address as input. */
ap = inet_ntoa(clientaddr.sin_addr);
port = ntohs(clientaddr.sin_port);
printf("Request received from");
if (hp != NULL)
printf(" %s", hp->h_name);
if (ap != NULL)
printf(" (%s)", ap);
printf(" port %d\n\"%s\"\n", port, databuf);
/* Send a response to the client. */
if (send(new_s, response, (int)strlen(response), 0) < 0)
{
perror("send");
FILE_CLOSE_((short)new_s);
continue;
}
FILE_CLOSE_((short)new_s);
}
FILE_CLOSE_((short)s);
}
AF_INET No-Wait Server Stub Routine
/*
* AF_INET 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. *
* * *
* *****************************************************************
*/
/* This is the same as the IPV4 sample server, but using nowaited I/O calls */
#include <systype.h>
#include <socket.h>
#include <errno.h>
#include <in.h>
#include <netdb.h>
#include <string.h>
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include <inet.h>
#include <tal.h>
#include <ctype.h>
#include <cextdecs.h>
#define SERVER_PORT 7639
#define CLIENT_PORT 7739
#define MAXBUFSIZE 4096
long tagBack;
short completedSocket;
short dcount;
212 Sample Programs