︙ | | |
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
|
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
|
-
-
+
+
|
4B8B16FE133A3B84007CD8B3 /* OFHashAlreadyCalculatedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B8B16FC133A3B84007CD8B3 /* OFHashAlreadyCalculatedException.h */; settings = {ATTRIBUTES = (Public, ); }; };
4B8B16FF133A3B84007CD8B3 /* OFHashAlreadyCalculatedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B8B16FD133A3B84007CD8B3 /* OFHashAlreadyCalculatedException.m */; };
4B8B170D133A3C11007CD8B3 /* OFConditionBroadcastFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B8B1702133A3B8E007CD8B3 /* OFConditionBroadcastFailedException.m */; };
4B8B170E133A3C11007CD8B3 /* OFConditionSignalFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B8B1704133A3B8E007CD8B3 /* OFConditionSignalFailedException.m */; };
4B8B170F133A3C11007CD8B3 /* OFConditionWaitFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B8B1706133A3B8E007CD8B3 /* OFConditionWaitFailedException.m */; };
4B90B78D133AD46700BD33CB /* OFAlreadyConnectedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B90B787133AD46700BD33CB /* OFAlreadyConnectedException.h */; settings = {ATTRIBUTES = (Public, ); }; };
4B90B78E133AD46700BD33CB /* OFAlreadyConnectedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B90B788133AD46700BD33CB /* OFAlreadyConnectedException.m */; };
4B90B78F133AD46700BD33CB /* OFNotConnectedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B90B789133AD46700BD33CB /* OFNotConnectedException.h */; settings = {ATTRIBUTES = (Public, ); }; };
4B90B790133AD46700BD33CB /* OFNotConnectedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B90B78A133AD46700BD33CB /* OFNotConnectedException.m */; };
4B90B78F133AD46700BD33CB /* OFNotOpenException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B90B789133AD46700BD33CB /* OFNotOpenException.h */; settings = {ATTRIBUTES = (Public, ); }; };
4B90B790133AD46700BD33CB /* OFNotOpenException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B90B78A133AD46700BD33CB /* OFNotOpenException.m */; };
4B90B791133AD46700BD33CB /* OFSetOptionFailedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B90B78B133AD46700BD33CB /* OFSetOptionFailedException.h */; settings = {ATTRIBUTES = (Public, ); }; };
4B90B792133AD46700BD33CB /* OFSetOptionFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B90B78C133AD46700BD33CB /* OFSetOptionFailedException.m */; };
4B90B79E133AD87D00BD33CB /* OFAcceptFailedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B90B794133AD87D00BD33CB /* OFAcceptFailedException.h */; settings = {ATTRIBUTES = (Public, ); }; };
4B90B79F133AD87D00BD33CB /* OFAcceptFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B90B795133AD87D00BD33CB /* OFAcceptFailedException.m */; };
4B90B7A0133AD87D00BD33CB /* OFAddressTranslationFailedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B90B796133AD87D00BD33CB /* OFAddressTranslationFailedException.h */; settings = {ATTRIBUTES = (Public, ); }; };
4B90B7A1133AD87D00BD33CB /* OFAddressTranslationFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B90B797133AD87D00BD33CB /* OFAddressTranslationFailedException.m */; };
4B90B7A2133AD87D00BD33CB /* OFBindFailedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B90B798133AD87D00BD33CB /* OFBindFailedException.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
︙ | | |
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
|
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
|
-
-
+
+
|
4B8B1702133A3B8E007CD8B3 /* OFConditionBroadcastFailedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFConditionBroadcastFailedException.m; path = src/exceptions/OFConditionBroadcastFailedException.m; sourceTree = "<group>"; };
4B8B1703133A3B8E007CD8B3 /* OFConditionSignalFailedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFConditionSignalFailedException.h; path = src/exceptions/OFConditionSignalFailedException.h; sourceTree = "<group>"; };
4B8B1704133A3B8E007CD8B3 /* OFConditionSignalFailedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFConditionSignalFailedException.m; path = src/exceptions/OFConditionSignalFailedException.m; sourceTree = "<group>"; };
4B8B1705133A3B8E007CD8B3 /* OFConditionWaitFailedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFConditionWaitFailedException.h; path = src/exceptions/OFConditionWaitFailedException.h; sourceTree = "<group>"; };
4B8B1706133A3B8E007CD8B3 /* OFConditionWaitFailedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFConditionWaitFailedException.m; path = src/exceptions/OFConditionWaitFailedException.m; sourceTree = "<group>"; };
4B90B787133AD46700BD33CB /* OFAlreadyConnectedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFAlreadyConnectedException.h; path = src/exceptions/OFAlreadyConnectedException.h; sourceTree = "<group>"; };
4B90B788133AD46700BD33CB /* OFAlreadyConnectedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFAlreadyConnectedException.m; path = src/exceptions/OFAlreadyConnectedException.m; sourceTree = "<group>"; };
4B90B789133AD46700BD33CB /* OFNotConnectedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFNotConnectedException.h; path = src/exceptions/OFNotConnectedException.h; sourceTree = "<group>"; };
4B90B78A133AD46700BD33CB /* OFNotConnectedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFNotConnectedException.m; path = src/exceptions/OFNotConnectedException.m; sourceTree = "<group>"; };
4B90B789133AD46700BD33CB /* OFNotOpenException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFNotOpenException.h; path = src/exceptions/OFNotOpenException.h; sourceTree = "<group>"; };
4B90B78A133AD46700BD33CB /* OFNotOpenException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFNotOpenException.m; path = src/exceptions/OFNotOpenException.m; sourceTree = "<group>"; };
4B90B78B133AD46700BD33CB /* OFSetOptionFailedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFSetOptionFailedException.h; path = src/exceptions/OFSetOptionFailedException.h; sourceTree = "<group>"; };
4B90B78C133AD46700BD33CB /* OFSetOptionFailedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFSetOptionFailedException.m; path = src/exceptions/OFSetOptionFailedException.m; sourceTree = "<group>"; };
4B90B794133AD87D00BD33CB /* OFAcceptFailedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFAcceptFailedException.h; path = src/exceptions/OFAcceptFailedException.h; sourceTree = "<group>"; };
4B90B795133AD87D00BD33CB /* OFAcceptFailedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFAcceptFailedException.m; path = src/exceptions/OFAcceptFailedException.m; sourceTree = "<group>"; };
4B90B796133AD87D00BD33CB /* OFAddressTranslationFailedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFAddressTranslationFailedException.h; path = src/exceptions/OFAddressTranslationFailedException.h; sourceTree = "<group>"; };
4B90B797133AD87D00BD33CB /* OFAddressTranslationFailedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFAddressTranslationFailedException.m; path = src/exceptions/OFAddressTranslationFailedException.m; sourceTree = "<group>"; };
4B90B798133AD87D00BD33CB /* OFBindFailedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFBindFailedException.h; path = src/exceptions/OFBindFailedException.h; sourceTree = "<group>"; };
|
︙ | | |
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
|
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
|
-
-
+
+
|
4B6743EC163C384A00EB1E59 /* OFLockFailedException.m */,
4B17FF9F133A3331003E6DCD /* OFMalformedXMLException.h */,
4B17FFA0133A3332003E6DCD /* OFMalformedXMLException.m */,
4B17FF8D133A3034003E6DCD /* OFMemoryNotPartOfObjectException.h */,
4B17FF8E133A3034003E6DCD /* OFMemoryNotPartOfObjectException.m */,
4B7DD5831894358400990FD6 /* OFMoveItemFailedException.h */,
4B7DD5841894358400990FD6 /* OFMoveItemFailedException.m */,
4B90B789133AD46700BD33CB /* OFNotConnectedException.h */,
4B90B78A133AD46700BD33CB /* OFNotConnectedException.m */,
4B17FF75133A2B18003E6DCD /* OFNotImplementedException.h */,
4B17FF76133A2B18003E6DCD /* OFNotImplementedException.m */,
4B90B789133AD46700BD33CB /* OFNotOpenException.h */,
4B90B78A133AD46700BD33CB /* OFNotOpenException.m */,
4B35C64C1ADAD30A003DB666 /* OFObserveFailedException.h */,
4B35C64D1ADAD30A003DB666 /* OFObserveFailedException.m */,
4B55A107133AC05100B58A93 /* OFOpenItemFailedException.h */,
4B55A108133AC05100B58A93 /* OFOpenItemFailedException.m */,
4B17FF81133A2DFB003E6DCD /* OFOutOfMemoryException.h */,
4B17FF82133A2DFB003E6DCD /* OFOutOfMemoryException.m */,
4B17FF79133A2C14003E6DCD /* OFOutOfRangeException.h */,
|
︙ | | |
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
|
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
|
-
+
|
4B17FFB9133A381D003E6DCD /* OFInvalidServerReplyException.h in Headers */,
4B29BC61133AC9CB0004B236 /* OFLinkFailedException.h in Headers */,
4B90B7A6133AD87D00BD33CB /* OFListenFailedException.h in Headers */,
4B6743F1163C384A00EB1E59 /* OFLockFailedException.h in Headers */,
4B17FFA1133A3335003E6DCD /* OFMalformedXMLException.h in Headers */,
4B17FF8F133A3036003E6DCD /* OFMemoryNotPartOfObjectException.h in Headers */,
4B7DD5851894358500990FD6 /* OFMoveItemFailedException.h in Headers */,
4B90B78F133AD46700BD33CB /* OFNotConnectedException.h in Headers */,
4B17FF77133A2B18003E6DCD /* OFNotImplementedException.h in Headers */,
4B90B78F133AD46700BD33CB /* OFNotOpenException.h in Headers */,
4B35C64E1ADAD30A003DB666 /* OFObserveFailedException.h in Headers */,
4B55A10A133AC05100B58A93 /* OFOpenItemFailedException.h in Headers */,
4B17FF83133A2DFB003E6DCD /* OFOutOfMemoryException.h in Headers */,
4B17FF7B133A2C15003E6DCD /* OFOutOfRangeException.h in Headers */,
4B55A112133AC24600B58A93 /* OFReadFailedException.h in Headers */,
4B55A114133AC24600B58A93 /* OFReadOrWriteFailedException.h in Headers */,
4BFF3714177E17C100192782 /* OFRemoveItemFailedException.h in Headers */,
|
︙ | | |
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
|
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
|
-
+
|
4B17FFBA133A381D003E6DCD /* OFInvalidServerReplyException.m in Sources */,
4B29BC62133AC9CB0004B236 /* OFLinkFailedException.m in Sources */,
4B90B7A7133AD87D00BD33CB /* OFListenFailedException.m in Sources */,
4B6743F2163C384A00EB1E59 /* OFLockFailedException.m in Sources */,
4B17FFA2133A3335003E6DCD /* OFMalformedXMLException.m in Sources */,
4B17FF90133A3036003E6DCD /* OFMemoryNotPartOfObjectException.m in Sources */,
4B7DD5861894358500990FD6 /* OFMoveItemFailedException.m in Sources */,
4B90B790133AD46700BD33CB /* OFNotConnectedException.m in Sources */,
4B17FF78133A2B18003E6DCD /* OFNotImplementedException.m in Sources */,
4B90B790133AD46700BD33CB /* OFNotOpenException.m in Sources */,
4B35C64F1ADAD30A003DB666 /* OFObserveFailedException.m in Sources */,
4B55A10B133AC05100B58A93 /* OFOpenItemFailedException.m in Sources */,
4B17FF84133A2DFB003E6DCD /* OFOutOfMemoryException.m in Sources */,
4B17FF7C133A2C15003E6DCD /* OFOutOfRangeException.m in Sources */,
4B55A113133AC24600B58A93 /* OFReadFailedException.m in Sources */,
4B55A115133AC24600B58A93 /* OFReadOrWriteFailedException.m in Sources */,
4BFF3715177E17C100192782 /* OFRemoveItemFailedException.m in Sources */,
|
︙ | | |
︙ | | |
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
-
+
|
#import "OFHTTPResponse.h"
#import "OFTCPSocket.h"
#import "OFTimer.h"
#import "OFAlreadyConnectedException.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFNotConnectedException.h"
#import "OFNotOpenException.h"
#import "OFOutOfMemoryException.h"
#import "OFOutOfRangeException.h"
#import "OFWriteFailedException.h"
#import "socket_helpers.h"
#define BUFFER_SIZE 1024
|
︙ | | |
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
-
+
|
- (void)lowlevelWriteBuffer: (const void*)buffer
length: (size_t)length
{
void *pool;
if (_socket == nil)
@throw [OFNotConnectedException exceptionWithSocket: self];
@throw [OFNotOpenException exceptionWithObject: self];
if (!_headersSent)
[self OF_sendHeaders];
if (!_chunked) {
[_socket writeBuffer: buffer
length: length];
|
︙ | | |
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
|
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
|
-
+
|
[_socket writeBuffer: "\r\n"
length: 2];
}
- (void)close
{
if (_socket == nil)
@throw [OFNotConnectedException exceptionWithSocket: self];
@throw [OFNotOpenException exceptionWithObject: self];
if (!_headersSent)
[self OF_sendHeaders];
if (_chunked)
[_socket writeBuffer: "0\r\n\r\n"
length: 5];
|
︙ | | |
︙ | | |
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
-
+
|
#include <errno.h>
#include <string.h>
#import "OFStreamSocket.h"
#import "OFInitializationFailedException.h"
#import "OFNotConnectedException.h"
#import "OFNotOpenException.h"
#import "OFOutOfRangeException.h"
#import "OFReadFailedException.h"
#import "OFSetOptionFailedException.h"
#import "OFWriteFailedException.h"
#import "socket_helpers.h"
|
︙ | | |
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
-
+
|
- (size_t)lowlevelReadIntoBuffer: (void*)buffer
length: (size_t)length
{
ssize_t ret;
if (_socket == INVALID_SOCKET)
@throw [OFNotConnectedException exceptionWithSocket: self];
@throw [OFNotOpenException exceptionWithObject: self];
if (_atEndOfStream)
@throw [OFReadFailedException exceptionWithObject: self
requestedLength: length
errNo: ENOTCONN];
#ifndef _WIN32
|
︙ | | |
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
-
+
|
return ret;
}
- (void)lowlevelWriteBuffer: (const void*)buffer
length: (size_t)length
{
if (_socket == INVALID_SOCKET)
@throw [OFNotConnectedException exceptionWithSocket: self];
@throw [OFNotOpenException exceptionWithObject: self];
if (_atEndOfStream)
@throw [OFWriteFailedException exceptionWithObject: self
requestedLength: length
errNo: ENOTCONN];
#ifndef _WIN32
|
︙ | | |
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
-
+
|
return (int)_socket;
#endif
}
- (void)close
{
if (_socket == INVALID_SOCKET)
@throw [OFNotConnectedException exceptionWithSocket: self];
@throw [OFNotOpenException exceptionWithObject: self];
close(_socket);
_socket = INVALID_SOCKET;
_atEndOfStream = false;
}
|
︙ | | |
︙ | | |
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
-
+
|
#import "OFAcceptFailedException.h"
#import "OFAlreadyConnectedException.h"
#import "OFBindFailedException.h"
#import "OFConnectionFailedException.h"
#import "OFGetOptionFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFListenFailedException.h"
#import "OFNotConnectedException.h"
#import "OFNotImplementedException.h"
#import "OFNotOpenException.h"
#import "OFOutOfMemoryException.h"
#import "OFSetOptionFailedException.h"
#import "socket.h"
#import "socket_helpers.h"
#import "resolver.h"
|
︙ | | |
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
|
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
|
-
+
|
{
[self listenWithBackLog: SOMAXCONN];
}
- (void)listenWithBackLog: (int)backLog
{
if (_socket == INVALID_SOCKET)
@throw [OFNotConnectedException exceptionWithSocket: self];
@throw [OFNotOpenException exceptionWithObject: self];
if (listen(_socket, backLog) == -1)
@throw [OFListenFailedException
exceptionWithSocket: self
backLog: backLog
errNo: of_socket_errno()];
|
︙ | | |
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
|
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
|
-
+
|
#endif
- (OFString*)remoteAddress
{
OFString *ret;
if (_socket == INVALID_SOCKET)
@throw [OFNotConnectedException exceptionWithSocket: self];
@throw [OFNotOpenException exceptionWithObject: self];
if (_address == NULL)
@throw [OFInvalidArgumentException exception];
of_address_to_string_and_port(_address, _addressLength, &ret, NULL);
return ret;
|
︙ | | |
︙ | | |
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
-
+
|
#endif
#import "OFRunLoop.h"
#import "OFRunLoop+Private.h"
#import "OFBindFailedException.h"
#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFNotConnectedException.h"
#import "OFNotOpenException.h"
#import "OFOutOfRangeException.h"
#import "OFReadFailedException.h"
#import "OFWriteFailedException.h"
#import "socket.h"
#import "socket_helpers.h"
#import "resolver.h"
|
︙ | | |
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
|
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
|
-
+
|
- (size_t)receiveIntoBuffer: (void*)buffer
length: (size_t)length
sender: (of_udp_socket_address_t*)sender
{
ssize_t ret;
if (_socket == INVALID_SOCKET)
@throw [OFNotConnectedException exceptionWithSocket: self];
@throw [OFNotOpenException exceptionWithObject: self];
sender->length = (socklen_t)sizeof(sender->address);
#ifndef _WIN32
if ((ret = recvfrom(_socket, buffer, length, 0,
(struct sockaddr*)&sender->address, &sender->length)) < 0)
@throw [OFReadFailedException
|
︙ | | |
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
|
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
|
-
+
|
#endif
- (void)sendBuffer: (const void*)buffer
length: (size_t)length
receiver: (of_udp_socket_address_t*)receiver
{
if (_socket == INVALID_SOCKET)
@throw [OFNotConnectedException exceptionWithSocket: self];
@throw [OFNotOpenException exceptionWithObject: self];
#ifndef _WIN32
if (sendto(_socket, buffer, length, 0,
(struct sockaddr*)&receiver->address, receiver->length) < length)
@throw [OFWriteFailedException
exceptionWithObject: self
requestedLength: length
|
︙ | | |
582
583
584
585
586
587
588
589
590
591
592
593
594
|
582
583
584
585
586
587
588
589
590
591
592
593
594
|
-
+
|
return (int)_socket;
#endif
}
- (void)close
{
if (_socket == INVALID_SOCKET)
@throw [OFNotConnectedException exceptionWithSocket: self];
@throw [OFNotOpenException exceptionWithObject: self];
close(_socket);
_socket = INVALID_SOCKET;
}
@end
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
/*
* Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015
* Jonathan Schleifer <js@webkeks.org>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFException.h"
#ifndef OF_HAVE_SOCKETS
# error No sockets available!
#endif
/*!
* @class OFNotConnectedException \
* OFNotConnectedException.h ObjFW/OFNotConnectedException.h
*
* @brief An exception indicating a socket is not connected or bound.
*/
@interface OFNotConnectedException: OFException
{
id _socket;
}
#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain) id socket;
#endif
/*!
* @brief Creates a new, autoreleased not connected exception.
*
* @param socket The socket which is not connected
* @return A new, autoreleased not connected exception
*/
+ (instancetype)exceptionWithSocket: (id)socket;
/*!
* @brief Initializes an already allocated not connected exception.
*
* @param socket The socket which is not connected
* @return An initialized not connected exception
*/
- initWithSocket: (id)socket;
/*!
* @brief Returns the socket which is not connected.
*
* @return The socket which is not connected
*/
- (id)socket;
@end
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
/*
* Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015
* Jonathan Schleifer <js@webkeks.org>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#import "OFNotConnectedException.h"
#import "OFString.h"
@implementation OFNotConnectedException
+ (instancetype)exceptionWithSocket: (id)socket
{
return [[[self alloc] initWithSocket: socket] autorelease];
}
- init
{
OF_INVALID_INIT_METHOD
}
- initWithSocket: (id)socket
{
self = [super init];
_socket = [socket retain];
return self;
}
- (void)dealloc
{
[_socket release];
[super dealloc];
}
- (OFString*)description
{
return [OFString stringWithFormat:
@"The socket of type %@ is not connected or bound!",
[_socket class]];
}
- (id)socket
{
OF_GETTER(_socket, true)
}
@end
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
/*
* Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015
* Jonathan Schleifer <js@webkeks.org>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#import "OFException.h"
/*!
* @class OFNotOpenException OFNotOpenException.h ObjFW/OFNotOpenException.h
*
* @brief An exception indicating an object is not open, connected or bound.
*/
@interface OFNotOpenException: OFException
{
id _object;
}
#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain) id object;
#endif
/*!
* @brief Creates a new, autoreleased not open exception.
*
* @param object The object which is not open, connected or bound
* @return A new, autoreleased not open exception
*/
+ (instancetype)exceptionWithObject: (id)object;
/*!
* @brief Initializes an already allocated not open exception.
*
* @param object The object which is not open, connected or bound
* @return An initialized not open exception
*/
- initWithObject: (id)object;
/*!
* @brief Returns the object which is not open, connected or bound.
*
* @return The object which is not open, connected or bound
*/
- (id)object;
@end
|
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |