ObjFW  Check-in [b5ea1b43c4]

Overview
Comment:One new exception; fix one FIXME in OFTCPSocket.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: b5ea1b43c4f711854adef094770276baf6c1db9669f0f0d345f05bb22743b7fa
User & Date: js on 2008-12-13 15:08:22
Other Links: manifest | tags
Context
2008-12-13
16:55
Update to latest rev of buildsys. check-in: a9ff3c4407 user: js tags: trunk
15:08
One new exception; fix one FIXME in OFTCPSocket. check-in: b5ea1b43c4 user: js tags: trunk
14:52
Fix 2 FIXMEs in OFTCPSocket. check-in: 7d05cee843 user: js tags: trunk
Changes

Modified src/OFExceptions.h from [78a34e9941] to [b6b180dc1e].

351
352
353
354
355
356
357















































- (const char*)node;

/**
 * \return The service of the node for which translation was requested
 */
- (const char*)service;
@end






















































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
401
402
403
404
- (const char*)node;

/**
 * \return The service of the node for which translation was requested
 */
- (const char*)service;
@end

/**
 * An OFException indicating that the connection could not be established.
 */
@interface OFConnectionFailedException: OFException
{
	char *host;
	uint16_t port;
}

/**
 * \param h The host to which the connection failed
 * \param p The port on the host to which the connection failed
 * \return A new connection failed exception
 */
+ newWithObject: (id)obj
	andHost: (const char*)h
	andPort: (uint16_t)p;

/**
 * Initializes an already allocated connection failed exception.
 *
 * \param h The host to which the connection failed
 * \param p The port on the host to which the connection failed
 * \return An initialized connection failed exception
 */
- initWithObject: (id)obj
	 andHost: (const char*)h
	 andPort: (uint16_t)p;

- free;

/**
 * \return An error message for the exception as a C string.
 */
- (const char*)cString;

/**
 * \return The host to which the connection failed
 */
- (const char*)host;

/**
 * \return The port on the host to which the connection failed
 */
- (uint16_t)port;
@end

Modified src/OFExceptions.m from [a965c66066] to [bdb764e78a].

378
379
380
381
382
383
384
385
386
387
388
389
390

391
392
393
394
395
396
397
398
399
400
401
402
403
404




















































}

- (const char*)cString
{
	if (string != NULL)
		return string;

	asprintf(&string, "The specified node with the specified service could "
	    "not be translated to an address for an object of type %s. This "
	    "means that either the node was not found, there is no such "
	    "service on the specified node, there was a problem with the name "
	    "server, there was a problem with your network connection or you "
	    "specified an invalid node or service.", [object name]);


	return string;
}

- (const char*)node
{
	return node;
}

- (const char*)service
{
	return service;
}
@end



























































|
|
|
<
|
|
>














>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
378
379
380
381
382
383
384
385
386
387

388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
}

- (const char*)cString
{
	if (string != NULL)
		return string;

	asprintf(&string, "The service %s on %s could not be translated to an "
	    "address for an object of type %s. This means that either the node "
	    "was not found, there is no such service on the node, there was a "

	    "problem with the name server, there was a problem with your "
	    "network connection or you specified an invalid node or service.",
	    service, node, [object name]);

	return string;
}

- (const char*)node
{
	return node;
}

- (const char*)service
{
	return service;
}
@end

@implementation OFConnectionFailedException
+ newWithObject: (id)obj
	andHost: (const char*)h
	andPort: (uint16_t)p
{
	return [self newWithObject: obj
			   andHost: h
			   andPort: p];
}

- initWithObject: (id)obj
	 andHost: (const char*)h
	 andPort: (uint16_t)p
{
	if ((self = [super initWithObject: obj])) {
		host = (h != NULL ? strdup(h) : NULL);
		port = p;
	}

	return self;
}

- free
{
	if (host != NULL)
		free(host);

	return [super free];
}

- (const char*)cString
{
	if (string != NULL)
		return string;

	asprintf(&string, "A connection to %s:%d could not be established in "
	    "object of type %s!", host, port, [object name]);

	return string;
}

- (const char*)host
{
	return host;
}

- (uint16_t)port
{
	return port;
}
@end

Modified src/OFTCPSocket.m from [0fd4ca4245] to [c69f2ecab6].

91
92
93
94
95
96
97
98
99
100
101

102
103
104
105
106
107
108
		}

		break;
	}
	
	freeaddrinfo(res0);

	if (sock < 0) {
		/* FIXME: Throw exception */
		return nil;
	}


	return self;
}

-    bindOn: (const char*)host
   withPort: (uint16_t)port
  andFamily: (int)family







|
|
|
<
>







91
92
93
94
95
96
97
98
99
100

101
102
103
104
105
106
107
108
		}

		break;
	}
	
	freeaddrinfo(res0);

	if (sock < 0)
		@throw [OFConnectionFailedException newWithObject: self
							  andHost: host

							  andPort: port];

	return self;
}

-    bindOn: (const char*)host
   withPort: (uint16_t)port
  andFamily: (int)family