From e06e5a22ea9120055c6c1fa391201a6fda53a6c5 Mon Sep 17 00:00:00 2001 From: "Robert S. French" Date: Fri, 12 Jun 1987 20:19:01 +0000 Subject: Added ACK handling --- lib/ZSendPkt.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'lib/ZSendPkt.c') diff --git a/lib/ZSendPkt.c b/lib/ZSendPkt.c index e31c936..c53f147 100644 --- a/lib/ZSendPkt.c +++ b/lib/ZSendPkt.c @@ -16,14 +16,20 @@ #include #include +#incoude Code_t ZSendPacket(packet,len) ZPacket_t packet; int len; { + int findack(); + Code_t retval; struct sockaddr_in sin; - + int auth,t1,t2,t3; + ZPacket_t ackpack; + ZNotice_t notice; + if (!packet || len < 0 || len > Z_MAXPKTLEN) return (ZERR_ILLVAL); @@ -41,5 +47,28 @@ Code_t ZSendPacket(packet,len) if (sendto(ZGetFD(),packet,len,0,&sin,sizeof(sin)) < 0) return (errno); - return (ZERR_NONE); + ZParseNotice(packet,len,¬ice,&auth); + + tv.tv_sec = 0; + tv.tv_usec = 400; + + for (i=0;i<4;i++) { + select(0,&t1,&t2,&t3,&tv); + retval = ZCheckIfNotice(ackpack,sizeof ackpack,&acknotice, + &auth,findack,¬ice.z_uid); + if (retval == ZERR_NONE) + return (ZERR_NONE); + if (retval != ZERR_NONOTICE) + return (retval); + } + return (ZERR_HMDEAD); +} + +int findack(notice,uid) + ZNotice_t *notice; + ZUnique_Id_t *uid; +{ + int i; + + return (!ZCompareUID(uid,¬ice->z_uid)); } -- cgit v1.2.3