ObjFW  Check-in [cecf1d4bf7]

Overview
Comment:Fix manually closing a TCP socket and improve automatic closing.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: cecf1d4bf78be850b3aaac5d3086b479b30ee530b301bb0bd391e01472c5f15f
User & Date: js on 2010-04-11 16:37:55
Other Links: manifest | tags
Context
2010-04-11
17:16
Allow OFAddressTranslationFailedExceptions without service and node. check-in: 6b22a15485 user: js tags: trunk
16:37
Fix manually closing a TCP socket and improve automatic closing. check-in: cecf1d4bf7 user: js tags: trunk
02:49
Add +[stringWithContentsOfFile:] to OFString. check-in: c7630df319 user: js tags: trunk
Changes

Modified src/OFTCPSocket.m from [f1cb5070ac] to [605f8714f2].

51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
51
52
53
54
55
56
57








58
59
60
61
62
63
64







-
-
-
-
-
-
-
-








	sock = INVALID_SOCKET;
	saddr = NULL;

	return self;
}

- (void)dealloc
{
	if (sock != INVALID_SOCKET)
		close(sock);

	[super dealloc];
}

- connectToService: (OFString*)service
	    onNode: (OFString*)node
{
	if (sock != INVALID_SOCKET)
		@throw [OFAlreadyConnectedException newWithClass: isa];

#ifdef HAVE_THREADSAFE_GETADDRINFO
379
380
381
382
383
384
385
386

387


388
389
390
391
392








393
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







-
+

+
+





+
+
+
+
+
+
+
+

}

- close
{
	if (sock == INVALID_SOCKET)
		@throw [OFNotConnectedException newWithClass: isa];

	[self freeMemory: saddr];
	close(sock);
	sock = INVALID_SOCKET;

	[self freeMemory: saddr];
	saddr = NULL;
	saddr_len = 0;

	return self;
}

- (void)dealloc
{
	if (sock != INVALID_SOCKET)
		[self close];

	[super dealloc];
}
@end