ObjFW  Check-in [bdfd9d0464]

Overview
Comment:Nicer way to create and initialize the socket in - accept.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: bdfd9d04645b3ad4790c9003bc015755da0af401c8e4c0548367a497b7f31e40
User & Date: js on 2009-05-02 15:33:54
Other Links: manifest | tags
Context
2009-05-03
14:20
Fix wrong free in OFString. Should be [self freeMem:]. check-in: 441e5ec29b user: js tags: trunk
2009-05-02
15:33
Nicer way to create and initialize the socket in - accept. check-in: bdfd9d0464 user: js tags: trunk
2009-05-01
22:28
Work around a compiler bug that occurs on OS X. check-in: 06ad922132 user: js tags: trunk
Changes

Modified src/OFTCPSocket.m from [5c6eb1441c] to [34c32e126e].

57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
{
	if (sock != INVALID_SOCKET)
		close(sock);

	return [super free];
}

- setSocket: (int)socket
{
	sock = socket;

	return self;
}

- setSocketAddress: (struct sockaddr*)sockaddr
	withLength: (socklen_t)len
{
	saddr = sockaddr;
	saddr_len = len;

	return self;
}

- connectTo: (const char*)host
     onPort: (uint16_t)port
{
	struct addrinfo hints, *res, *res0;
	char portstr[6];

	if (!port)







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







57
58
59
60
61
62
63
















64
65
66
67
68
69
70
{
	if (sock != INVALID_SOCKET)
		close(sock);

	return [super free];
}

















- connectTo: (const char*)host
     onPort: (uint16_t)port
{
	struct addrinfo hints, *res, *res0;
	char portstr[6];

	if (!port)
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
	}

	if ((s = accept(sock, addr, &addrlen)) == INVALID_SOCKET) {
		[newsock free];
		@throw [OFAcceptFailedException newWithClass: isa];
	}

	[newsock setSocket: s];
	[newsock setSocketAddress: addr
		       withLength: addrlen];

	return newsock;
}

- (size_t)readNBytes: (size_t)size
	  intoBuffer: (char*)buf
{







|
|
|







195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
	}

	if ((s = accept(sock, addr, &addrlen)) == INVALID_SOCKET) {
		[newsock free];
		@throw [OFAcceptFailedException newWithClass: isa];
	}

	newsock->sock = s;
	newsock->saddr = addr;
	newsock->saddr_len = addrlen;

	return newsock;
}

- (size_t)readNBytes: (size_t)size
	  intoBuffer: (char*)buf
{