|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 /* |
|
7 ** Subclass definitions for network I/O (ref: prio.h) |
|
8 */ |
|
9 |
|
10 #if defined(_RCNETIO_H) |
|
11 #else |
|
12 #define _RCNETIO_H |
|
13 |
|
14 #include "rcbase.h" |
|
15 #include "rcinrval.h" |
|
16 #include "rcio.h" |
|
17 #include "rcnetdb.h" |
|
18 |
|
19 #include "prio.h" |
|
20 |
|
21 class RCFileInfo; |
|
22 |
|
23 /* |
|
24 ** Class: RCNetStreamIO (ref prio.h) |
|
25 ** |
|
26 ** Streamed (reliable) network I/O (e.g., TCP). |
|
27 ** This class hides (makes private) the functions that are not applicable |
|
28 ** to network I/O (i.e., those for file I/O). |
|
29 */ |
|
30 |
|
31 class PR_IMPLEMENT(RCNetStreamIO): public RCIO |
|
32 { |
|
33 |
|
34 public: |
|
35 RCNetStreamIO(); |
|
36 virtual ~RCNetStreamIO(); |
|
37 |
|
38 virtual RCIO* Accept(RCNetAddr* addr, const RCInterval& timeout); |
|
39 virtual PRInt32 AcceptRead( |
|
40 RCIO **nd, RCNetAddr **raddr, void *buf, |
|
41 PRSize amount, const RCInterval& timeout); |
|
42 virtual PRInt64 Available(); |
|
43 virtual PRStatus Bind(const RCNetAddr& addr); |
|
44 virtual PRStatus Connect( |
|
45 const RCNetAddr& addr, const RCInterval& timeout); |
|
46 virtual PRStatus GetLocalName(RCNetAddr *addr) const; |
|
47 virtual PRStatus GetPeerName(RCNetAddr *addr) const; |
|
48 virtual PRStatus GetSocketOption(PRSocketOptionData *data) const; |
|
49 virtual PRStatus Listen(PRIntn backlog); |
|
50 virtual PRInt16 Poll(PRInt16 in_flags, PRInt16 *out_flags); |
|
51 virtual PRInt32 Read(void *buf, PRSize amount); |
|
52 virtual PRInt32 Recv( |
|
53 void *buf, PRSize amount, PRIntn flags, |
|
54 const RCInterval& timeout); |
|
55 virtual PRInt32 Recvfrom( |
|
56 void *buf, PRSize amount, PRIntn flags, |
|
57 RCNetAddr* addr, const RCInterval& timeout); |
|
58 virtual PRInt32 Send( |
|
59 const void *buf, PRSize amount, PRIntn flags, |
|
60 const RCInterval& timeout); |
|
61 virtual PRInt32 Sendto( |
|
62 const void *buf, PRSize amount, PRIntn flags, |
|
63 const RCNetAddr& addr, |
|
64 const RCInterval& timeout); |
|
65 virtual PRStatus SetSocketOption(const PRSocketOptionData *data); |
|
66 virtual PRStatus Shutdown(ShutdownHow how); |
|
67 virtual PRInt32 TransmitFile( |
|
68 RCIO *source, const void *headers, |
|
69 PRSize hlen, RCIO::FileDisposition flags, |
|
70 const RCInterval& timeout); |
|
71 virtual PRInt32 Write(const void *buf, PRSize amount); |
|
72 virtual PRInt32 Writev( |
|
73 const PRIOVec *iov, PRSize size, |
|
74 const RCInterval& timeout); |
|
75 |
|
76 private: |
|
77 /* functions unavailable to this clients of this class */ |
|
78 RCNetStreamIO(const RCNetStreamIO&); |
|
79 |
|
80 PRStatus Close(); |
|
81 PRStatus Open(const char *name, PRIntn flags, PRIntn mode); |
|
82 PRStatus FileInfo(RCFileInfo *info) const; |
|
83 PRStatus Fsync(); |
|
84 PRInt64 Seek(PRInt64 offset, RCIO::Whence how); |
|
85 |
|
86 public: |
|
87 RCNetStreamIO(PRIntn protocol); |
|
88 }; /* RCNetIO */ |
|
89 |
|
90 #endif /* defined(_RCNETIO_H) */ |
|
91 |
|
92 /* RCNetStreamIO.h */ |
|
93 |
|
94 |