diff --git a/Source/NSMessagePort.m b/Source/NSMessagePort.m index 3b7dc34d9..2faccb042 100644 --- a/Source/NSMessagePort.m +++ b/Source/NSMessagePort.m @@ -902,12 +902,17 @@ static Class runLoopClass; int res = 0; unsigned len = sizeof(res); - if (getsockopt(desc, SOL_SOCKET, SO_ERROR, (char*)&res, &len) == 0 - && res != 0) + if (getsockopt(desc, SOL_SOCKET, SO_ERROR, (char*)&res, &len) != 0) { state = GS_H_UNCON; NSLog(@"connect attempt failed - %@", [NSError _last]); } + else if (res != 0) + { + state = GS_H_UNCON; + NSLog(@"connect attempt failed - %@", + [NSError _systemError: res]); + } else { NSData *d = newDataWithEncodedPort([self recvPort]); diff --git a/Source/NSSocketPort.m b/Source/NSSocketPort.m index c82fd0bc3..b78c05638 100644 --- a/Source/NSSocketPort.m +++ b/Source/NSSocketPort.m @@ -1104,12 +1104,16 @@ static Class runLoopClass; int res = 0; unsigned len = sizeof(res); - if (getsockopt(desc, SOL_SOCKET, SO_ERROR, (char*)&res, &len) == 0 - && res != 0) + if (getsockopt(desc, SOL_SOCKET, SO_ERROR, (char*)&res, &len) != 0) { state = GS_H_UNCON; NSLog(@"connect attempt failed - %@", [NSError _last]); } + else if (res != 0) + { + state = GS_H_UNCON; + NSLog(@"connect attempt failed - %@", [NSError _systemError: res]); + } else { NSData *d = newDataWithEncodedPort([self recvPort]);