Differences From Artifact [fe6d461e93]:
- File src/OFTCPSocket.m — part of check-in [062a052b50] at 2010-04-17 15:46:34 on branch trunk — Don't return self where not necessary, return void or something useful. (user: js, size: 9003) [annotate] [blame] [check-ins using]
To Artifact [dd20905993]:
- File
src/OFTCPSocket.m
— part of check-in
[37db8f0fb3]
at
2010-04-17 22:27:17
on branch trunk
— New ivar naming convention.
ivars are now named like this: thisIsAnIVar. If an accessor exists for
the ivar, the ivar is named like the accessor. This is required for
@property to work. (user: js, size: 9032) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
49 50 51 52 53 54 55 | #endif - init { self = [super init]; sock = INVALID_SOCKET; | | | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | #endif - init { self = [super init]; sock = INVALID_SOCKET; sockAddr = NULL; return self; } - (void)connectToService: (OFString*)service onNode: (OFString*)node { |
︙ | ︙ | |||
345 346 347 348 349 350 351 | if ((s = accept(sock, addr, &addrlen)) == INVALID_SOCKET) { [newsock dealloc]; @throw [OFAcceptFailedException newWithClass: isa]; } newsock->sock = s; | | | | | | | | 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 | if ((s = accept(sock, addr, &addrlen)) == INVALID_SOCKET) { [newsock dealloc]; @throw [OFAcceptFailedException newWithClass: isa]; } newsock->sock = s; newsock->sockAddr = addr; newsock->sockAddrLen = addrlen; return newsock; } - (void)setKeepAlivesEnabled: (BOOL)enable { int v = enable; if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (char*)&v, sizeof(v))) @throw [OFSetOptionFailedException newWithClass: isa]; } - (OFString*)remoteAddress { if (sockAddr == NULL || sockAddrLen == 0) @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; #ifdef HAVE_THREADSAFE_GETADDRINFO char *node = [self allocMemoryWithSize: NI_MAXHOST]; @try { if (getnameinfo(sockAddr, sockAddrLen, node, NI_MAXHOST, NULL, 0, NI_NUMERICHOST)) @throw [OFAddressTranslationFailedException newWithClass: isa]; return [OFString stringWithCString: node]; } @finally { [self freeMemory: node]; } #else char *node; # ifdef OF_THREADS [mutex lock]; @try { # endif node = inet_ntoa(((struct sockaddr_in*)sockAddr)->sin_addr); if (node == NULL) @throw [OFAddressTranslationFailedException newWithClass: isa]; return [OFString stringWithCString: node]; # ifdef OF_THREADS |
︙ | ︙ | |||
412 413 414 415 416 417 418 | { if (sock == INVALID_SOCKET) @throw [OFNotConnectedException newWithClass: isa]; close(sock); sock = INVALID_SOCKET; | | | | | 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 | { if (sock == INVALID_SOCKET) @throw [OFNotConnectedException newWithClass: isa]; close(sock); sock = INVALID_SOCKET; [self freeMemory: sockAddr]; sockAddr = NULL; sockAddrLen = 0; } - (void)dealloc { if (sock != INVALID_SOCKET) [self close]; [super dealloc]; } @end |