* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
static char sccsid
[] = "@(#)acksend.c 2.2 (Berkeley) %G%";
#include <protocols/timed.h>
#define SECFORACK 1 /* seconds */
#define USECFORACK 0 /* microseconds */
* Acksend implements reliable datagram transmission by using sequence
* numbers and retransmission when necessary.
* `name' is the name of the destination
* `addr' is the address to send to
* If `name' is ANYADDR, this routine implements reliable broadcast.
struct tsp
*acksend(message
, addr
, name
, ack
, net
)
struct sockaddr_in
*addr
;
message
->tsp_vers
= TSPVERSION
;
message
->tsp_seq
= sequence
;
fprintf(fd
, "acksend: ");
fprintf(fd
, "broadcast: ");
fprintf(fd
, "%s: ", name
);
if (sendto(sock
, (char *)message
, sizeof(struct tsp
), 0, addr
,
sizeof(struct sockaddr_in
)) < 0) {
syslog(LOG_ERR
, "acksend: sendto: %m");
tout
.tv_usec
= USECFORACK
;
answer
= readmsg(ack
, name
, &tout
, net
);
if (answer
->tsp_seq
!= sequence
) {
fprintf(fd
, "acksend: seq # %d != %d\n",
answer
->tsp_seq
, sequence
);
if (++count
== MAXCOUNT
) {
} while (flag
!= RECEIVED
);