1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is the Netscape Portable Runtime (NSPR).
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998-2000
20 * the Initial Developer. All Rights Reserved.
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
39 ** Base class definitions for I/O (ref: prio.h)
41 ** This class is a virtual base class. Construction must be done by a
42 ** subclass, but the I/O operations can be done on a RCIO object reference.
57 class PR_IMPLEMENT(RCIO): public RCBase
61 open = PR_TRANSMITFILE_KEEP_OPEN, /* socket is left open after file
63 close = PR_TRANSMITFILE_CLOSE_SOCKET/* socket is closed after file
68 set = PR_SEEK_SET, /* Set to value specified */
69 current = PR_SEEK_CUR, /* Seek relative to current position */
70 end = PR_SEEK_END /* seek past end of current eof */
74 recv = PR_SHUTDOWN_RCV, /* receives will be disallowed */
75 send = PR_SHUTDOWN_SEND, /* sends will be disallowed */
76 both = PR_SHUTDOWN_BOTH /* sends & receives will be disallowed */
82 virtual RCIO* Accept(RCNetAddr* addr, const RCInterval& timeout) = 0;
83 virtual PRInt32 AcceptRead(
84 RCIO **nd, RCNetAddr **raddr, void *buf,
85 PRSize amount, const RCInterval& timeout) = 0;
86 virtual PRInt64 Available() = 0;
87 virtual PRStatus Bind(const RCNetAddr& addr) = 0;
88 virtual PRStatus Close() = 0;
89 virtual PRStatus Connect(
90 const RCNetAddr& addr,
91 const RCInterval& timeout) = 0;
92 virtual PRStatus FileInfo(RCFileInfo *info) const = 0;
93 virtual PRStatus Fsync() = 0;
94 virtual PRStatus GetLocalName(RCNetAddr *addr) const = 0;
95 virtual PRStatus GetPeerName(RCNetAddr *addr) const = 0;
96 virtual PRStatus GetSocketOption(PRSocketOptionData *data) const = 0;
97 virtual PRStatus Listen(PRIntn backlog) = 0;
98 virtual PRStatus Open(const char *name, PRIntn flags, PRIntn mode) = 0;
99 virtual PRInt16 Poll(PRInt16 in_flags, PRInt16 *out_flags) = 0;
100 virtual PRInt32 Read(void *buf, PRSize amount) = 0;
101 virtual PRInt32 Recv(
102 void *buf, PRSize amount, PRIntn flags,
103 const RCInterval& timeout) = 0;
104 virtual PRInt32 Recvfrom(
105 void *buf, PRSize amount, PRIntn flags,
106 RCNetAddr* addr, const RCInterval& timeout) = 0;
107 virtual PRInt64 Seek(PRInt64 offset, Whence how) = 0;
108 virtual PRInt32 Send(
109 const void *buf, PRSize amount, PRIntn flags,
110 const RCInterval& timeout) = 0;
111 virtual PRInt32 Sendto(
112 const void *buf, PRSize amount, PRIntn flags,
113 const RCNetAddr& addr,
114 const RCInterval& timeout) = 0;
115 virtual PRStatus SetSocketOption(const PRSocketOptionData *data) = 0;
116 virtual PRStatus Shutdown(ShutdownHow how) = 0;
117 virtual PRInt32 TransmitFile(
118 RCIO *source, const void *headers,
119 PRSize hlen, RCIO::FileDisposition flags,
120 const RCInterval& timeout) = 0;
121 virtual PRInt32 Write(const void *buf, PRSize amount) = 0;
122 virtual PRInt32 Writev(
123 const PRIOVec *iov, PRSize size,
124 const RCInterval& timeout) = 0;
129 tcp = PR_DESC_SOCKET_TCP,
130 udp = PR_DESC_SOCKET_UDP,
131 layered = PR_DESC_LAYERED} RCIOType;
135 PRFileDesc *fd; /* where the real code hides */
138 /* no default construction and no copies allowed */
144 #endif /* defined(_RCIO_H) */