@@ -68,7 +68,7 @@ - (BOOL)connectSocketWithError:(NSError *__autoreleasing *)error
68
68
{
69
69
int sock = socket (AF_INET, SOCK_STREAM, 0 );
70
70
if (sock < 0 ) {
71
- return [NWErrorUtil noWithErrorCode: kNWErrorSocketCreate error: error];
71
+ return [NWErrorUtil noWithErrorCode: kNWErrorSocketCreate reason: sock error: error];
72
72
}
73
73
struct sockaddr_in addr;
74
74
memset (&addr, 0 , sizeof (struct sockaddr_in));
@@ -83,15 +83,15 @@ - (BOOL)connectSocketWithError:(NSError *__autoreleasing *)error
83
83
addr.sin_family = AF_INET;
84
84
int conn = connect (sock, (struct sockaddr *)&addr, sizeof (struct sockaddr_in));
85
85
if (conn < 0 ) {
86
- return [NWErrorUtil noWithErrorCode: kNWErrorSocketConnect error: error];
86
+ return [NWErrorUtil noWithErrorCode: kNWErrorSocketConnect reason: conn error: error];
87
87
}
88
88
int cntl = fcntl (sock, F_SETFL, O_NONBLOCK);
89
89
if (cntl < 0 ) {
90
- return [NWErrorUtil noWithErrorCode: kNWErrorSocketFileControl error: error];
90
+ return [NWErrorUtil noWithErrorCode: kNWErrorSocketFileControl reason: cntl error: error];
91
91
}
92
92
int set = 1 , sopt = setsockopt (sock, SOL_SOCKET, SO_NOSIGPIPE, (void *)&set, sizeof (int ));
93
93
if (sopt < 0 ) {
94
- return [NWErrorUtil noWithErrorCode: kNWErrorSocketOptions error: error];
94
+ return [NWErrorUtil noWithErrorCode: kNWErrorSocketOptions reason: sopt error: error];
95
95
}
96
96
_socket = sock;
97
97
return YES ;
@@ -105,19 +105,19 @@ - (BOOL)connectSSLWithError:(NSError *__autoreleasing *)error
105
105
}
106
106
OSStatus setio = SSLSetIOFuncs (context, NWSSLRead, NWSSLWrite);
107
107
if (setio != errSecSuccess) {
108
- return [NWErrorUtil noWithErrorCode: kNWErrorSSLIOFuncs error: error];
108
+ return [NWErrorUtil noWithErrorCode: kNWErrorSSLIOFuncs reason: setio error: error];
109
109
}
110
110
OSStatus setconn = SSLSetConnection (context, (SSLConnectionRef)(NSInteger )_socket);
111
111
if (setconn != errSecSuccess) {
112
- return [NWErrorUtil noWithErrorCode: kNWErrorSSLConnection error: error];
112
+ return [NWErrorUtil noWithErrorCode: kNWErrorSSLConnection reason: setconn error: error];
113
113
}
114
114
OSStatus setpeer = SSLSetPeerDomainName (context, _host.UTF8String , strlen (_host.UTF8String ));
115
115
if (setpeer != errSecSuccess) {
116
- return [NWErrorUtil noWithErrorCode: kNWErrorSSLPeerDomainName error: error];
116
+ return [NWErrorUtil noWithErrorCode: kNWErrorSSLPeerDomainName reason: setpeer error: error];
117
117
}
118
118
OSStatus setcert = SSLSetCertificate (context, (__bridge CFArrayRef)@[_identity]);
119
119
if (setcert != errSecSuccess) {
120
- return [NWErrorUtil noWithErrorCode: kNWErrorSSLCertificate error: error];
120
+ return [NWErrorUtil noWithErrorCode: kNWErrorSSLCertificate reason: setcert error: error];
121
121
}
122
122
_context = context;
123
123
return YES ;
@@ -141,7 +141,7 @@ - (BOOL)handshakeSSLWithError:(NSError *__autoreleasing *)error
141
141
case errSSLClientCertRequested: return [NWErrorUtil noWithErrorCode: kNWErrorSSLHandshakeClientCertRequested error: error];
142
142
case errSSLServerAuthCompleted: return [NWErrorUtil noWithErrorCode: kNWErrorSSLHandshakeServerAuthCompleted error: error];
143
143
}
144
- return [NWErrorUtil noWithErrorCode: kNWErrorSSLHandshakeFail error: error];
144
+ return [NWErrorUtil noWithErrorCode: kNWErrorSSLHandshakeFail reason: status error: error];
145
145
}
146
146
147
147
- (void )disconnect
@@ -166,7 +166,7 @@ - (BOOL)read:(NSMutableData *)data length:(NSUInteger *)length error:(NSError *_
166
166
case errSSLClosedAbort: return [NWErrorUtil noWithErrorCode: kNWErrorReadClosedAbort error: error];
167
167
case errSSLClosedGraceful: return [NWErrorUtil noWithErrorCode: kNWErrorReadClosedGraceful error: error];
168
168
}
169
- return [NWErrorUtil noWithErrorCode: kNWErrorReadFail error: error];
169
+ return [NWErrorUtil noWithErrorCode: kNWErrorReadFail reason: status error: error];
170
170
}
171
171
172
172
- (BOOL )write : (NSData *)data length : (NSUInteger *)length error : (NSError *__autoreleasing *)error
@@ -182,7 +182,7 @@ - (BOOL)write:(NSData *)data length:(NSUInteger *)length error:(NSError *__autor
182
182
case errSSLClosedAbort: return [NWErrorUtil noWithErrorCode: kNWErrorWriteClosedAbort error: error];
183
183
case errSSLClosedGraceful: return [NWErrorUtil noWithErrorCode: kNWErrorWriteClosedGraceful error: error];
184
184
}
185
- return [NWErrorUtil noWithErrorCode: kNWErrorWriteFail error: error];
185
+ return [NWErrorUtil noWithErrorCode: kNWErrorWriteFail reason: status error: error];
186
186
}
187
187
188
188
@end
0 commit comments