@@ -27,12 +27,12 @@ #import "OFStreamObserver.h" #import "OFArray.h" #import "OFDictionary.h" #import "OFStream.h" #import "OFDataArray.h" -#ifdef _WIN32 -# import "OFTCPSocket.h" +#ifndef OF_HAVE_PIPE +# import "OFStreamSocket.h" #endif #ifdef OF_HAVE_THREADS # import "OFMutex.h" #endif #import "OFDate.h" @@ -96,11 +96,11 @@ - init { self = [super init]; @try { -#ifdef _WIN32 +#ifndef OF_HAVE_PIPE struct sockaddr_in cancelAddr2; socklen_t cancelAddrLen; #endif _readStreams = [[OFMutableArray alloc] init]; @@ -108,17 +108,17 @@ _queue = [[OFMutableArray alloc] init]; _queueInfo = [[OFDataArray alloc] initWithItemSize: sizeof(int)]; _queueFDs = [[OFDataArray alloc] initWithItemSize: sizeof(int)]; -#ifndef _WIN32 +#ifdef OF_HAVE_PIPE if (pipe(_cancelFD)) @throw [OFInitializationFailedException exceptionWithClass: [self class]]; #else - /* Make sure WSAStartup has been called */ - [OFTCPSocket class]; + /* Make sure network has been initialized */ + [OFStreamSocket class]; _cancelFD[0] = socket(AF_INET, SOCK_DGRAM, 0); _cancelFD[1] = socket(AF_INET, SOCK_DGRAM, 0); if (_cancelFD[0] == INVALID_SOCKET || @@ -136,11 +136,10 @@ (struct sockaddr*)&cancelAddr2, sizeof(cancelAddr2))) @throw [OFInitializationFailedException exceptionWithClass: [self class]]; cancelAddrLen = sizeof(_cancelAddr); - if (getsockname(_cancelFD[0], (struct sockaddr*)&_cancelAddr, &cancelAddrLen)) @throw [OFInitializationFailedException exceptionWithClass: [self class]]; #endif @@ -385,11 +384,11 @@ return [self observeForTimeInterval: [date timeIntervalSinceNow]]; } - (void)cancel { -#ifndef _WIN32 +#ifdef OF_HAVE_PIPE OF_ENSURE(write(_cancelFD[1], "", 1) > 0); #else OF_ENSURE(sendto(_cancelFD[1], "", 1, 0, (struct sockaddr*)&_cancelAddr, sizeof(_cancelAddr)) > 0); #endif