From ba066c34dde204aa192d03a23a81356374d93731 Mon Sep 17 00:00:00 2001 From: chatty Date: Wed, 7 Apr 1993 11:50:31 +0000 Subject: Initial revision --- comm/OLD/dgram.h | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 comm/OLD/dgram.h (limited to 'comm/OLD/dgram.h') diff --git a/comm/OLD/dgram.h b/comm/OLD/dgram.h new file mode 100644 index 0000000..143687e --- /dev/null +++ b/comm/OLD/dgram.h @@ -0,0 +1,102 @@ +/* + * The Unix Channel + * + * by Michel Beaudouin-Lafon + * + * Copyright 1990-1993 + * Laboratoire de Recherche en Informatique (LRI) + * + * Reliable datagrams - to be updated + * + * $Id$ + * $CurLog$ + */ + +#ifndef _DGRAM_H_ +#define _DGRAM_H_ + +#include "global.h" +#include "Datagram.h" +#include "ccu/IdTable.h" +#include "ccu/List.h" +#include "ccu/Timer.h" + +class UchDGRAM; +class UchMessage; + +class UchDGRAM_TIMER : public CcuBaseTimer { +protected: + UchDGRAM& dgram; + void Handle (Millisecond); + +public: + UchDGRAM_TIMER (UchDGRAM&); + ~UchDGRAM_TIMER (); +}; + +class UchDGRAM : public UchDatagram { +protected: + CcuIdTable pending; // pending messages + sword npending; // number of pending messages + short retry; // retry times + CcuList input; // input messages + sword ninput; // number of input messages + pUchAddress fromAddr; // address of last acknowledged message + lword outId; // id of message sent + UchDGRAM_TIMER timer; // timer to resend + Millisecond timeout; // timeout for timer + short locked; + bool resend; + bool sync; + + void Init (); + int GetInput (int); + bool CheckInput (); + bool WaitInput (); + + void SendAck (lword, UchAddress&); + void Expired (); + UchMsgBuffer* PrepareToSend (UchAddress&, int retries); + int SendBuffer (UchMsgBuffer&, UchAddress&); + void RemovePending (lword); + bool Wait (lword); + void Lock () { locked++; } + void Unlock () { if (--locked == 0 && resend) Resend (); } + +public: + UchDGRAM (); + UchDGRAM (UchAddress*, UchAddress*); + ~UchDGRAM (); + + int Send (byte*, int, UchAddress&, bool = FALSE, int retries = 0); + int Receive (byte*, int); + int Reply (byte*, int, bool = FALSE, int retries = 0); + + int Send (UchMsgBuffer&, UchAddress&, bool = FALSE, bool = FALSE, int retries = 0); + int Receive (UchMsgBuffer&); + int Reply (UchMsgBuffer&, bool = FALSE, bool = FALSE, int retries = 0); + + bool Send (UchMessage&, UchAddress&, bool = FALSE, int retries = 0); + bool Receive (UchMessage* msg); + bool Reply (UchMessage&, bool = FALSE, int retries = 0); + +virtual bool DiscardNotify (UchMsgBuffer&, UchAddress&); + + int NumPending () { return npending; } + int NumInput () { return ninput; } + void SetRetry (short r) { retry = r; } + void SetRetryTime (Millisecond); + void SetSync (bool s) { sync = s; if (s) Drain (); } + + void Resend (); + void Drain (); + +virtual bool NewMessage (UchMsgBuffer&); + void HandleRead (); + bool HandleSelect (); + +friend class UchDGRAM_TIMER; +}; + +#endif /* _DGRAM_H_ */ + -- cgit v1.1