michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* michael@0: ** Base class definitions for I/O (ref: prio.h) michael@0: ** michael@0: ** This class is a virtual base class. Construction must be done by a michael@0: ** subclass, but the I/O operations can be done on a RCIO object reference. michael@0: */ michael@0: michael@0: #if defined(_RCIO_H) michael@0: #else michael@0: #define _RCIO_H michael@0: michael@0: #include "rcbase.h" michael@0: #include "rcnetdb.h" michael@0: #include "rcinrval.h" michael@0: michael@0: #include "prio.h" michael@0: michael@0: class RCFileInfo; michael@0: michael@0: class PR_IMPLEMENT(RCIO): public RCBase michael@0: { michael@0: public: michael@0: typedef enum { michael@0: open = PR_TRANSMITFILE_KEEP_OPEN, /* socket is left open after file michael@0: * is transmitted. */ michael@0: close = PR_TRANSMITFILE_CLOSE_SOCKET/* socket is closed after file michael@0: * is transmitted. */ michael@0: } FileDisposition; michael@0: michael@0: typedef enum { michael@0: set = PR_SEEK_SET, /* Set to value specified */ michael@0: current = PR_SEEK_CUR, /* Seek relative to current position */ michael@0: end = PR_SEEK_END /* seek past end of current eof */ michael@0: } Whence; michael@0: michael@0: typedef enum { michael@0: recv = PR_SHUTDOWN_RCV, /* receives will be disallowed */ michael@0: send = PR_SHUTDOWN_SEND, /* sends will be disallowed */ michael@0: both = PR_SHUTDOWN_BOTH /* sends & receives will be disallowed */ michael@0: } ShutdownHow; michael@0: michael@0: public: michael@0: virtual ~RCIO(); michael@0: michael@0: virtual RCIO* Accept(RCNetAddr* addr, const RCInterval& timeout) = 0; michael@0: virtual PRInt32 AcceptRead( michael@0: RCIO **nd, RCNetAddr **raddr, void *buf, michael@0: PRSize amount, const RCInterval& timeout) = 0; michael@0: virtual PRInt64 Available() = 0; michael@0: virtual PRStatus Bind(const RCNetAddr& addr) = 0; michael@0: virtual PRStatus Close() = 0; michael@0: virtual PRStatus Connect( michael@0: const RCNetAddr& addr, michael@0: const RCInterval& timeout) = 0; michael@0: virtual PRStatus FileInfo(RCFileInfo *info) const = 0; michael@0: virtual PRStatus Fsync() = 0; michael@0: virtual PRStatus GetLocalName(RCNetAddr *addr) const = 0; michael@0: virtual PRStatus GetPeerName(RCNetAddr *addr) const = 0; michael@0: virtual PRStatus GetSocketOption(PRSocketOptionData *data) const = 0; michael@0: virtual PRStatus Listen(PRIntn backlog) = 0; michael@0: virtual PRStatus Open(const char *name, PRIntn flags, PRIntn mode) = 0; michael@0: virtual PRInt16 Poll(PRInt16 in_flags, PRInt16 *out_flags) = 0; michael@0: virtual PRInt32 Read(void *buf, PRSize amount) = 0; michael@0: virtual PRInt32 Recv( michael@0: void *buf, PRSize amount, PRIntn flags, michael@0: const RCInterval& timeout) = 0; michael@0: virtual PRInt32 Recvfrom( michael@0: void *buf, PRSize amount, PRIntn flags, michael@0: RCNetAddr* addr, const RCInterval& timeout) = 0; michael@0: virtual PRInt64 Seek(PRInt64 offset, Whence how) = 0; michael@0: virtual PRInt32 Send( michael@0: const void *buf, PRSize amount, PRIntn flags, michael@0: const RCInterval& timeout) = 0; michael@0: virtual PRInt32 Sendto( michael@0: const void *buf, PRSize amount, PRIntn flags, michael@0: const RCNetAddr& addr, michael@0: const RCInterval& timeout) = 0; michael@0: virtual PRStatus SetSocketOption(const PRSocketOptionData *data) = 0; michael@0: virtual PRStatus Shutdown(ShutdownHow how) = 0; michael@0: virtual PRInt32 TransmitFile( michael@0: RCIO *source, const void *headers, michael@0: PRSize hlen, RCIO::FileDisposition flags, michael@0: const RCInterval& timeout) = 0; michael@0: virtual PRInt32 Write(const void *buf, PRSize amount) = 0; michael@0: virtual PRInt32 Writev( michael@0: const PRIOVec *iov, PRSize size, michael@0: const RCInterval& timeout) = 0; michael@0: michael@0: protected: michael@0: typedef enum { michael@0: file = PR_DESC_FILE, michael@0: tcp = PR_DESC_SOCKET_TCP, michael@0: udp = PR_DESC_SOCKET_UDP, michael@0: layered = PR_DESC_LAYERED} RCIOType; michael@0: michael@0: RCIO(RCIOType); michael@0: michael@0: PRFileDesc *fd; /* where the real code hides */ michael@0: michael@0: private: michael@0: /* no default construction and no copies allowed */ michael@0: RCIO(); michael@0: RCIO(const RCIO&); michael@0: michael@0: }; /* RCIO */ michael@0: michael@0: #endif /* defined(_RCIO_H) */ michael@0: michael@0: /* RCIO.h */ michael@0: michael@0: