]> err.no Git - sope/blob - sope-core/NGStreams/NGStreams/NGSocketExceptions.h
Id fixes
[sope] / sope-core / NGStreams / NGStreams / NGSocketExceptions.h
1 /*
2   Copyright (C) 2000-2003 SKYRIX Software AG
3
4   This file is part of OGo
5
6   OGo is free software; you can redistribute it and/or modify it under
7   the terms of the GNU Lesser General Public License as published by the
8   Free Software Foundation; either version 2, or (at your option) any
9   later version.
10
11   OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12   WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14   License for more details.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with OGo; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21 // $Id$
22
23 #ifndef __NGNet_NGSocketExceptions_H__
24 #define __NGNet_NGSocketExceptions_H__
25
26 #import <Foundation/NSException.h>
27 #include <NGStreams/NGStreamExceptions.h>
28 #include <NGStreams/NGSocketProtocols.h>
29
30 /*
31   Exceptions:
32
33     NGIOException
34       NGSocketException
35         NGSocketBindException
36           NGSocketAlreadyBoundException
37           NGCouldNotBindSocketException
38         NGSocketConnectionException
39           NGSocketNotConnectedException
40           NGSocketAlreadyConnectedException
41           NGCouldNotConnectException
42         NGSocketOptionException
43           NGCouldNotSetSocketOptionException
44           NGCouldNotGetSocketOptionException
45         NGCouldNotResolveHostNameException
46         NGDidNotFindServiceException
47         NGSocketIsAlreadyListeningException
48         NGCouldNotListenException
49         NGCouldNotAcceptException
50         NGInvalidSocketDomainException
51         NGCouldNotCreateSocketException
52       NGStreamException
53         NGEndOfStreamException
54           NGSocketShutdownException
55             NGSocketShutdownDuringReadException
56             NGSocketShutdownDuringWriteException
57             NGSocketConnectionResetException
58             NGSocketTimedOutException
59 */
60
61 @interface NGSocketException : NGIOException
62 {
63 @protected
64   id<NGSocket> socket;
65 }
66
67 - (id)init;
68 - (id)initWithReason:(NSString *)_reason;
69 - (id)initWithReason:(NSString *)_reason socket:(id<NGSocket>)_socket;
70
71 - (id<NGSocket>)socket;
72
73 @end
74
75 @interface NGCouldNotResolveHostNameException : NGSocketException
76 {
77 @protected
78   NSString *hostName;
79 }
80
81 - (id)initWithHostName:(NSString *)_name reason:(NSString *)_reason;
82
83 - (NSString *)hostName;
84
85 @end
86
87 @interface NGDidNotFindServiceException : NGSocketException
88 {
89 @protected
90   NSString *serviceName;
91 }
92
93 - (id)init;
94 - (id)initWithServiceName:(NSString *)_service;
95
96 - (NSString *)serviceName;
97
98 @end
99
100 @interface NGInvalidSocketDomainException : NGSocketException
101 {
102 @protected
103   id<NGSocketDomain> domain;
104 }
105
106 - (id)initWithReason:(NSString *)_reason
107   socket:(id<NGSocket>)_socket domain:(id<NGSocketDomain>)_domain;
108
109 @end
110
111 @interface NGCouldNotCreateSocketException : NGSocketException
112 {
113 @protected
114   id<NGSocketDomain> domain;
115 }
116
117 - (id)init;
118 - (id)initWithReason:(NSString *)_reason domain:(id<NGSocketDomain>)_domain;
119
120 @end
121
122 // ******************** bind ***********************
123
124 @interface NGSocketBindException : NGSocketException
125 @end
126
127 @interface NGSocketAlreadyBoundException : NGSocketBindException
128 @end
129
130 @interface NGCouldNotBindSocketException : NGSocketBindException
131 {
132 @protected
133   id<NGSocketAddress> address;
134 }
135
136 - (id)initWithReason:(NSString *)_reason
137   socket:(id<NGSocket>)_socket address:(id<NGSocketAddress>)address;
138
139 - (id<NGSocketAddress>)address;
140
141 @end
142
143 // ******************** connect ********************
144
145 @interface NGSocketConnectException : NGSocketException
146 @end
147
148 @interface NGSocketNotConnectedException : NGSocketConnectException
149 @end
150
151 @interface NGSocketAlreadyConnectedException : NGSocketConnectException
152 @end
153
154 @interface NGCouldNotConnectException : NGSocketConnectException
155 {
156 @protected
157   id<NGSocketAddress> address;
158 }
159
160 - (id)initWithReason:(NSString *)_reason
161   socket:(id<NGActiveSocket>)_socket
162   address:(id<NGSocketAddress>)address;
163
164 - (id<NGSocketAddress>)address;
165
166 @end
167
168 // ******************** listen ********************
169
170 @interface NGSocketIsAlreadyListeningException : NGSocketException
171 @end
172
173 @interface NGCouldNotListenException : NGSocketException
174 @end
175
176 // ******************** accept ********************
177
178 @interface NGCouldNotAcceptException : NGSocketException
179 @end
180
181 // ******************** options ********************
182
183 @interface NGSocketOptionException : NGSocketException
184 {
185 @protected
186   int option;
187   int level;
188 }
189
190 - (id)init;
191 - (id)initWithReason:(NSString *)_reason option:(int)_option level:(int)_level;
192
193 @end
194
195 @interface NGCouldNotSetSocketOptionException : NGSocketOptionException
196 @end
197
198 @interface NGCouldNotGetSocketOptionException : NGSocketOptionException
199 @end
200
201 // ******************** socket closed **************
202
203 @interface NGSocketShutdownException : NGEndOfStreamException
204
205 - (id)initWithReason:(NSString *)_reason;
206 - (id)initWithReason:(NSString *)_reason socket:(id<NGActiveSocket>)_socket;
207 - (id)initWithSocket:(id<NGActiveSocket>)_socket;
208
209 /* Note: this only returns a valid ptr, if the socket is still retained ! */
210 - (id<NGActiveSocket>)socket;
211
212 @end
213
214 @interface NGSocketShutdownDuringReadException : NGSocketShutdownException
215 @end
216
217 @interface NGSocketShutdownDuringWriteException : NGSocketShutdownException
218 @end
219
220 @interface NGSocketTimedOutException : NGSocketShutdownException
221 @end
222
223 @interface NGSocketConnectionResetException : NGSocketShutdownException
224 @end
225
226 #endif /* __NGNet_NGSocketExceptions_H__ */