Bug 60768
| Summary: | xinetd service echo-udp performs only once | ||
|---|---|---|---|
| Product: | [Retired] Red Hat Linux | Reporter: | Wilhelm Engels <wilhelm.engels> |
| Component: | xinetd | Assignee: | Trond Eivind Glomsrxd <teg> |
| Status: | CLOSED DUPLICATE | QA Contact: | Brock Organ <borgan> |
| Severity: | medium | Docs Contact: | |
| Priority: | medium | ||
| Version: | 7.2 | ||
| Target Milestone: | --- | ||
| Target Release: | --- | ||
| Hardware: | i386 | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | Bug Fix | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2002-03-06 07:12:39 UTC | Type: | --- |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
|
Description
Wilhelm Engels
2002-03-06 07:07:15 UTC
testprg
--- cut here ---
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <netdb.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/param.h>
#include <netinet/in.h>
int main(int argc, char *argv[])
{
struct timeval time_out; /* struct timeout on select */
struct sockaddr_in Sin; /* socket address send */
struct hostent *hp; /* struct to get internet address */
struct servent *sp; /* struct to get internet service */
fd_set echo_fds; /* area for select bits */
char ebuf[64]; /* send / receive buffer */
int efd; /* socket for send */
size_t rlen; /* size of returned structed from echo */
int eret; /* return value, received */
char hostn[MAXHOSTNAMELEN]; /* for the hostname */
strncpy(hostn, argv[1], MAXHOSTNAMELEN);
if (!(hp = gethostbyname(hostn))) /* get ip addr */
{
fprintf(stderr,
"%s: unknown host %s\n", argv[0], hostn);
exit(2);
}
if (!(sp = getservbyname("echo", "udp")))
{
fprintf(stderr,
"%s: echo not in services\n", argv[0]);
exit(3);
}
if ((efd = socket(PF_INET,SOCK_DGRAM,0)) < 0)
{
fprintf(stderr, "%s: open socket:%s\n",
argv[0],
strerror(errno));
exit(4);
}
Sin.sin_family = PF_INET; /* internet */
(void) memcpy((char *) &Sin.sin_addr.s_addr, /* put in remote host */
(char *) hp->h_addr,
sizeof(unsigned long));
Sin.sin_port = (unsigned short) sp->s_port; /* save port */
strcpy(ebuf, "calping"); /* send message */
eret=sendto(
efd, /* fileid of socket */
ebuf, /* buffer */
(int) strlen(ebuf),
0,
(struct sockaddr *) &Sin,
sizeof(Sin));
if (-1 > eret)
{
fprintf(stderr, "%s:sendto:%s\n",
argv[0],
strerror(errno));
exit(5);
}
time_out.tv_sec = 1L; /* seconds to wait */
time_out.tv_usec = 0L; /* milliseconds */
FD_ZERO(&echo_fds); /* clear all bits */
FD_SET(efd, &echo_fds); /* file descriptor */
if (!(eret = select(
FD_SETSIZE, /* check all fds */
&echo_fds, /* read check */
0, /* no write check */
0, /* no execptions */
&time_out))) /* time out periode */
{
fprintf(stderr, "%s:timeout select\n",
argv[0]);
exit(1); /* got timeout */
}
if (0 > eret) /* error */
{
fprintf(stderr, "%s:error select:%s\n",
argv[0],
strerror(errno));
exit(7);
}
rlen = sizeof(Sin); /* available space */
(void) recvfrom(
efd, /* file id to read */
ebuf, /* buffer */
64, /* length of buffer */
0, /* flags */
(struct sockaddr *) &Sin, /* sender address */
&rlen); /* size of struct */
fprintf(stderr, "%s:got response\n",
argv[0]);
exit(0); /* return other sys exist */
}
|