@@ -153,12 +153,13 @@ { OFString *destinationHost = host; uint16_t destinationPort = port; if (sock != INVALID_SOCKET) - @throw [OFAlreadyConnectedException exceptionWithClass: isa - socket: self]; + @throw [OFAlreadyConnectedException + exceptionWithClass: [self class] + socket: self]; if (SOCKS5Host != nil) { /* Connect to the SOCKS5 proxy instead */ host = SOCKS5Host; port = SOCKS5Port; @@ -174,11 +175,11 @@ snprintf(portCString, 7, "%" PRIu16, port); if (getaddrinfo([host cStringWithEncoding: OF_STRING_ENCODING_NATIVE], portCString, &hints, &res0)) @throw [OFAddressTranslationFailedException - exceptionWithClass: isa + exceptionWithClass: [self class] socket: self host: host]; for (res = res0; res != NULL; res = res->ai_next) { if ((sock = socket(res->ai_family, res->ai_socktype, @@ -212,11 +213,11 @@ # ifdef OF_THREADS [addrlist release]; [mutex unlock]; # endif @throw [OFAddressTranslationFailedException - exceptionWithClass: isa + exceptionWithClass: [self class] socket: self host: host]; } memset(&addr, 0, sizeof(addr)); @@ -227,12 +228,13 @@ (sock = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) { # ifdef OF_THREADS [addrlist release]; [mutex unlock]; # endif - @throw [OFConnectionFailedException exceptionWithClass: isa - socket: self + @throw [OFConnectionFailedException + exceptionWithClass: [self class] + socket: self host: host port: port]; } # ifdef OF_THREADS @@ -271,14 +273,15 @@ sock = INVALID_SOCKET; } #endif if (sock == INVALID_SOCKET) - @throw [OFConnectionFailedException exceptionWithClass: isa - socket: self - host: host - port: port]; + @throw [OFConnectionFailedException + exceptionWithClass: [self class] + socket: self + host: host + port: port]; if (SOCKS5Host != nil) [self _SOCKS5ConnectToHost: destinationHost port: destinationPort]; } @@ -292,16 +295,18 @@ struct sockaddr_in6 in6; } addr; socklen_t addrLen; if (sock != INVALID_SOCKET) - @throw [OFAlreadyConnectedException exceptionWithClass: isa - socket: self]; + @throw [OFAlreadyConnectedException + exceptionWithClass: [self class] + socket: self]; if (SOCKS5Host != nil) - @throw [OFNotImplementedException exceptionWithClass: isa - selector: _cmd]; + @throw [OFNotImplementedException + exceptionWithClass: [self class] + selector: _cmd]; #ifdef HAVE_THREADSAFE_GETADDRINFO struct addrinfo hints, *res; char portCString[7]; @@ -311,25 +316,25 @@ snprintf(portCString, 7, "%" PRIu16, port); if (getaddrinfo([host cStringWithEncoding: OF_STRING_ENCODING_NATIVE], portCString, &hints, &res)) @throw [OFAddressTranslationFailedException - exceptionWithClass: isa + exceptionWithClass: [self class] socket: self host: host]; if ((sock = socket(res->ai_family, SOCK_STREAM, 0)) == INVALID_SOCKET) - @throw [OFBindFailedException exceptionWithClass: isa + @throw [OFBindFailedException exceptionWithClass: [self class] socket: self host: host port: port]; if (bind(sock, res->ai_addr, res->ai_addrlen) == -1) { freeaddrinfo(res); close(sock); sock = INVALID_SOCKET; - @throw [OFBindFailedException exceptionWithClass: isa + @throw [OFBindFailedException exceptionWithClass: [self class] socket: self host: host port: port]; } @@ -345,11 +350,11 @@ OF_STRING_ENCODING_NATIVE])) == NULL) { # ifdef OF_THREADS [mutex unlock]; # endif @throw [OFAddressTranslationFailedException - exceptionWithClass: isa + exceptionWithClass: [self class] socket: self host: host]; } memset(&addr, 0, sizeof(addr)); @@ -359,11 +364,11 @@ if (he->h_addrtype != AF_INET || he->h_addr_list[0] == NULL) { # ifdef OF_THREADS [mutex unlock]; # endif @throw [OFAddressTranslationFailedException - exceptionWithClass: isa + exceptionWithClass: [self class] socket: self host: host]; } memcpy(&addr.in.sin_addr.s_addr, he->h_addr_list[0], he->h_length); @@ -370,19 +375,19 @@ # ifdef OF_THREADS [mutex unlock]; # endif if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) - @throw [OFBindFailedException exceptionWithClass: isa + @throw [OFBindFailedException exceptionWithClass: [self class] socket: self host: host port: port]; if (bind(sock, (struct sockaddr*)&addr.in, sizeof(addr.in)) == -1) { close(sock); sock = INVALID_SOCKET; - @throw [OFBindFailedException exceptionWithClass: isa + @throw [OFBindFailedException exceptionWithClass: [self class] socket: self host: host port: port]; } #endif @@ -392,11 +397,11 @@ addrLen = sizeof(addr.storage); if (getsockname(sock, (struct sockaddr*)&addr, &addrLen)) { close(sock); sock = INVALID_SOCKET; - @throw [OFBindFailedException exceptionWithClass: isa + @throw [OFBindFailedException exceptionWithClass: [self class] socket: self host: host port: port]; } @@ -405,38 +410,38 @@ if (addr.storage.ss_family == AF_INET6) return of_bswap16_if_le(addr.in6.sin6_port); close(sock); sock = INVALID_SOCKET; - @throw [OFBindFailedException exceptionWithClass: isa + @throw [OFBindFailedException exceptionWithClass: [self class] socket: self host: host port: port]; } - (void)listenWithBackLog: (int)backLog { if (sock == INVALID_SOCKET) - @throw [OFNotConnectedException exceptionWithClass: isa + @throw [OFNotConnectedException exceptionWithClass: [self class] socket: self]; if (listen(sock, backLog) == -1) - @throw [OFListenFailedException exceptionWithClass: isa + @throw [OFListenFailedException exceptionWithClass: [self class] socket: self backLog: backLog]; listening = YES; } - (void)listen { if (sock == INVALID_SOCKET) - @throw [OFNotConnectedException exceptionWithClass: isa + @throw [OFNotConnectedException exceptionWithClass: [self class] socket: self]; if (listen(sock, 5) == -1) - @throw [OFListenFailedException exceptionWithClass: isa + @throw [OFListenFailedException exceptionWithClass: [self class] socket: self backLog: 5]; listening = YES; } @@ -446,11 +451,11 @@ OFTCPSocket *newSocket; struct sockaddr_storage *addr; socklen_t addrLen; int newSock; - newSocket = [[[isa alloc] init] autorelease]; + newSocket = [[[[self class] alloc] init] autorelease]; addrLen = sizeof(struct sockaddr); @try { addr = [newSocket allocMemoryWithSize: sizeof(struct sockaddr)]; } @catch (id e) { @@ -459,11 +464,11 @@ } if ((newSock = accept(sock, (struct sockaddr*)addr, &addrLen)) == INVALID_SOCKET) { [newSocket release]; - @throw [OFAcceptFailedException exceptionWithClass: isa + @throw [OFAcceptFailedException exceptionWithClass: [self class] socket: self]; } newSocket->sock = newSock; newSocket->sockAddr = addr; @@ -475,30 +480,32 @@ - (void)setKeepAlivesEnabled: (BOOL)enable { int v = enable; if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (char*)&v, sizeof(v))) - @throw [OFSetOptionFailedException exceptionWithClass: isa - stream: self]; + @throw [OFSetOptionFailedException + exceptionWithClass: [self class] + stream: self]; } - (OFString*)remoteAddress { char *host; if (sockAddr == NULL || sockAddrLen == 0) - @throw [OFInvalidArgumentException exceptionWithClass: isa - selector: _cmd]; + @throw [OFInvalidArgumentException + exceptionWithClass: [self class] + selector: _cmd]; #ifdef HAVE_THREADSAFE_GETADDRINFO host = [self allocMemoryWithSize: NI_MAXHOST]; @try { if (getnameinfo((struct sockaddr*)sockAddr, sockAddrLen, host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST)) @throw [OFAddressTranslationFailedException - exceptionWithClass: isa]; + exceptionWithClass: [self class]]; return [OFString stringWithCString: host encoding: OF_STRING_ENCODING_NATIVE]; } @finally { [self freeMemory: host]; @@ -511,11 +518,11 @@ # endif host = inet_ntoa(((struct sockaddr_in*)sockAddr)->sin_addr); if (host == NULL) @throw [OFAddressTranslationFailedException - exceptionWithClass: isa]; + exceptionWithClass: [self class]]; return [OFString stringWithCString: host encoding: OF_STRING_ENCODING_NATIVE]; # ifdef OF_THREADS } @finally {