author | terom |
Wed, 17 Dec 2008 00:40:22 +0000 | |
changeset 381 | 9b35bc329d23 |
parent 380 | d193dd1d8a7e |
child 382 | 190f81d30624 |
permissions | -rw-r--r-- |
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
1 |
#ifndef NETWORK_SOCKET_HH |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
2 |
#define NETWORK_SOCKET_HH |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
3 |
|
380 | 4 |
// forward-declare |
5 |
class NetworkSocket; |
|
6 |
||
186 | 7 |
#include "../Error.hh" |
378
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
8 |
#include "Address.hh" |
381
9b35bc329d23
separate sockaddr stuff out of NetworkAddress... now called NetworkEndpoint
terom
parents:
380
diff
changeset
|
9 |
#include "SockAddr.hh" |
380 | 10 |
#include "Reactor.hh" |
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
11 |
|
378
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
12 |
/* |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
13 |
* Platform-specific includes |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
14 |
*/ |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
15 |
#ifndef WIN32 |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
16 |
// linux |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
17 |
#include <sys/types.h> |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
18 |
#include <sys/socket.h> |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
19 |
#include <unistd.h> |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
20 |
#include <fcntl.h> |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
21 |
|
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
22 |
#define closesocket close |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
23 |
#else |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
24 |
#error "This network code won't compile on win32 :)" |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
25 |
#endif |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
26 |
|
284 | 27 |
/** |
378
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
28 |
* We use ClanLib's Socket API, but with our own extensions... |
284 | 29 |
*/ |
378
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
30 |
class NetworkSocket { |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
31 |
private: |
380 | 32 |
/** |
33 |
* Socket family/type/protocol |
|
34 |
*/ |
|
35 |
struct socket_type { |
|
36 |
/** Socket domain */ |
|
37 |
int family; |
|
38 |
||
39 |
/** Socket type */ |
|
40 |
int socktype; |
|
41 |
||
42 |
/** Socket protocol */ |
|
43 |
int protocol; |
|
44 |
||
45 |
/** Simple constructor */ |
|
46 |
socket_type (int family = 0, int socktype = 0, int protocol = 0) : family(family), socktype(socktype), protocol(protocol) { } |
|
47 |
}; |
|
48 |
||
49 |
/** These are nonzero if given via the constructor, used to filter out unwanted addrinfos */ |
|
50 |
socket_type sock_type; |
|
51 |
||
378
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
52 |
/** The file descriptor */ |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
53 |
int fd; |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
54 |
|
380 | 55 |
/** Our current type, intialized via constructor, but updated by lazy_socket */ |
56 |
socket_type type; |
|
378
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
57 |
|
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
58 |
/** |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
59 |
* Has the socket been explicitly bind()'d? If so, force ourselves to use this socket in connect(). |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
60 |
*/ |
380 | 61 |
bool bound : 1; |
62 |
||
63 |
/** |
|
64 |
* Registered to reactor? |
|
65 |
*/ |
|
66 |
bool registered : 1; |
|
67 |
||
68 |
/** |
|
69 |
* Do we want to know about recv()s? |
|
70 |
*/ |
|
71 |
bool want_read : 1; |
|
72 |
||
73 |
/** |
|
74 |
* Is the write buffer full? |
|
75 |
*/ |
|
76 |
bool want_write : 1; |
|
77 |
||
78 |
/** |
|
79 |
* The reactor that we use, defaults to NetworkReactor::current |
|
80 |
*/ |
|
81 |
NetworkReactor *reactor; |
|
378
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
82 |
|
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
83 |
/** |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
84 |
* Read/write signals |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
85 |
*/ |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
86 |
CL_Signal_v0 _sig_read, _sig_write; |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
87 |
|
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
88 |
public: |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
89 |
/** |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
90 |
* Construct a socket of the specific type. Family and protocol can be left as NULL, but type should usually |
380 | 91 |
* be specified. The given reactor is used for polling, defaults to NetworkReactor::current |
378
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
92 |
*/ |
380 | 93 |
NetworkSocket (int family, int socktype, int protocol = 0, NetworkReactor *reactor = NULL); |
378
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
94 |
|
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
95 |
/** |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
96 |
* Create a socket from the given pre-existing fd |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
97 |
*/ |
380 | 98 |
NetworkSocket (int fd, socket_type type, NetworkReactor *reactor = NULL); |
378
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
99 |
|
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
100 |
/** |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
101 |
* Force-close the socket if it's still open |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
102 |
*/ |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
103 |
~NetworkSocket (void); |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
104 |
|
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
105 |
private: |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
106 |
// XXX: nocopy |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
107 |
|
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
108 |
/** |
380 | 109 |
* Reset bound+poll |
110 |
*/ |
|
111 |
void reset (void); |
|
112 |
||
113 |
/** |
|
378
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
114 |
* Create a new socket of the given type, unless we already have one |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
115 |
*/ |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
116 |
void lazy_socket (int family, int type, int protocol); |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
117 |
|
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
118 |
/** |
380 | 119 |
* Close and reset, ignoring errors |
378
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
120 |
*/ |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
121 |
void force_close (void); |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
122 |
|
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
123 |
public: |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
124 |
/** |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
125 |
* Get the socket fd... promise not to break it |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
126 |
*/ |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
127 |
int get_socket (void) const { return fd; } |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
128 |
|
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
129 |
/** |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
130 |
* Bind to a specific local address |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
131 |
*/ |
381
9b35bc329d23
separate sockaddr stuff out of NetworkAddress... now called NetworkEndpoint
terom
parents:
380
diff
changeset
|
132 |
void bind (const NetworkEndpoint &addr); |
378
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
133 |
|
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
134 |
/** |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
135 |
* Put socket into listen mode |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
136 |
*/ |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
137 |
void listen (int backlog); |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
138 |
|
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
139 |
/** |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
140 |
* Get local address |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
141 |
*/ |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
142 |
NetworkAddress get_local_address (void); |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
143 |
|
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
144 |
/** |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
145 |
* Get remote address |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
146 |
*/ |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
147 |
NetworkAddress get_remote_address (void); |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
148 |
|
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
149 |
/** |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
150 |
* Make send/recv/connect non-blocking |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
151 |
*/ |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
152 |
void set_nonblocking (bool nonblocking); |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
153 |
|
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
154 |
/** |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
155 |
* Accept a new connection, optionally giving the connection's source address |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
156 |
*/ |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
157 |
NetworkSocket* accept (NetworkAddress *src); |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
158 |
|
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
159 |
/** |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
160 |
* Establish a new connection |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
161 |
*/ |
381
9b35bc329d23
separate sockaddr stuff out of NetworkAddress... now called NetworkEndpoint
terom
parents:
380
diff
changeset
|
162 |
void connect (const NetworkEndpoint &addr); |
378
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
163 |
|
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
164 |
/** |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
165 |
* Send, optionally using the specific destination |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
166 |
* |
381
9b35bc329d23
separate sockaddr stuff out of NetworkAddress... now called NetworkEndpoint
terom
parents:
380
diff
changeset
|
167 |
* @param buf bytes to send |
9b35bc329d23
separate sockaddr stuff out of NetworkAddress... now called NetworkEndpoint
terom
parents:
380
diff
changeset
|
168 |
* @param size how many bytes to try and send |
9b35bc329d23
separate sockaddr stuff out of NetworkAddress... now called NetworkEndpoint
terom
parents:
380
diff
changeset
|
169 |
* @param dest optional specific destination address |
378
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
170 |
* @return number of bytes sent, zero if busy |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
171 |
* @throw NetworkSocketError on error |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
172 |
*/ |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
173 |
size_t send (const char *buf, size_t size, const NetworkAddress *dest = NULL); |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
174 |
|
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
175 |
/** |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
176 |
* Recv, optionally storing the source in src |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
177 |
* |
381
9b35bc329d23
separate sockaddr stuff out of NetworkAddress... now called NetworkEndpoint
terom
parents:
380
diff
changeset
|
178 |
* @param buf where to recv into |
9b35bc329d23
separate sockaddr stuff out of NetworkAddress... now called NetworkEndpoint
terom
parents:
380
diff
changeset
|
179 |
* @param size how many bytes to try and receive |
9b35bc329d23
separate sockaddr stuff out of NetworkAddress... now called NetworkEndpoint
terom
parents:
380
diff
changeset
|
180 |
* @param src optionally store source address |
378
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
181 |
* @return number of bytes received, zero if none available |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
182 |
* @throw NetworkSocketEOFError if the connection was closed |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
183 |
* @throw NetworkSocketError on error |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
184 |
*/ |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
185 |
size_t recv (char *buf, size_t size, NetworkAddress *src = NULL); |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
186 |
|
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
187 |
/** |
380 | 188 |
* Close and reset the socket |
378
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
189 |
*/ |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
190 |
void close (void); |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
191 |
|
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
192 |
/** |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
193 |
* Triggered when socket becomes readable |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
194 |
*/ |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
195 |
CL_Signal_v0& sig_read (void) { return _sig_read; } |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
196 |
|
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
197 |
/** |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
198 |
* Triggered when socket becomes writeable after a send that returned zero |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
199 |
*/ |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
200 |
CL_Signal_v0& sig_write (void) { return _sig_write; } |
380 | 201 |
|
202 |
/** |
|
203 |
* Register to NetworkReactor unless already registered |
|
204 |
*/ |
|
205 |
void register_poll (void); |
|
206 |
||
207 |
/** |
|
208 |
* Trigger sig_read() once socket is ready for recv? |
|
209 |
*/ |
|
210 |
void set_poll_read (bool want_read) { this->want_read = want_read; if (!registered) register_poll(); } |
|
211 |
||
212 |
/** |
|
213 |
* Trigger sig_write() once socket is ready for send? |
|
214 |
*/ |
|
215 |
void set_poll_write (bool want_write) { this->want_write = want_write; if (!registered) register_poll(); } |
|
216 |
||
217 |
/** |
|
218 |
* What events this socket is interested in. |
|
219 |
*/ |
|
220 |
NetworkPollMask get_poll (void) { |
|
221 |
return (want_read ? POLL_READ : 0) | (want_write ? POLL_WRITE : 0); |
|
222 |
} |
|
223 |
||
224 |
/** |
|
225 |
* Notify of events |
|
226 |
*/ |
|
227 |
void notify (NetworkPollMask mask) { |
|
228 |
if (mask & POLL_READ) _sig_read(); |
|
229 |
if (mask & POLL_WRITE) _sig_write(); |
|
230 |
} |
|
378
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
231 |
}; |
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
232 |
|
284 | 233 |
/** |
234 |
* Base class for expcetions thrown by socket methods |
|
235 |
*/ |
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
236 |
class NetworkSocketError : public Error { |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
237 |
protected: |
378
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
238 |
static std::string build_str (const NetworkSocket &socket, const char *op, const char *err); |
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
239 |
|
5589abf5e61b
break the network code. Too late to set up a branch for this now
terom
parents:
284
diff
changeset
|
240 |
public: |
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
241 |
NetworkSocketError (const NetworkSocket &socket, const char *op, const char *err); |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
242 |
}; |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
243 |
|
284 | 244 |
/** |
245 |
* Errno-enabled exception, most common type of NetworkSocketError |
|
246 |
*/ |
|
380 | 247 |
class NetworkSocketErrno : public NetworkSocketError { |
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
248 |
public: |
380 | 249 |
NetworkSocketErrno (const NetworkSocket &socket, const char *op); |
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
250 |
}; |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
251 |
|
284 | 252 |
/** |
253 |
* Recv returned EOF |
|
254 |
*/ |
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
255 |
class NetworkSocketEOFError : public NetworkSocketError { |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
256 |
public: |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
257 |
NetworkSocketEOFError (const NetworkSocket &socket, const char *op) : |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
258 |
NetworkSocketError(socket, op, "EOF") { } |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
259 |
}; |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
260 |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
261 |
#endif /* NETWORK_SOCKET_HH */ |