ObjFW  Check-in [273d5b90f8]

Overview
Comment:Clean up OFStream and OFSocket interface.
This allows better compile-time checks.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 273d5b90f8c443318be684decfada66e3d6ec8079e8b533e35d2ccaa3d267ff0
User & Date: js on 2010-01-22 18:40:04
Other Links: manifest | tags
Context
2010-01-22
18:52
Differentiate more between OFArray and OFMutableArray in tests. check-in: 7e47fcb96a user: js tags: trunk
18:40
Clean up OFStream and OFSocket interface.
This allows better compile-time checks.
check-in: 273d5b90f8 user: js tags: trunk
2010-01-17
13:11
uintptr_t might be better here. check-in: 453532ccf3 user: js tags: trunk
Changes

Modified src/OFSocket.h from [ac924aea1f] to [7dfa9cbdaf].

51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
 */
+ socket;

/**
 * Enables/disables non-blocking I/O.
 */
- setBlocking: (BOOL)enable;

- connectToService: (OFString*)service
	    onNode: (OFString*)node;
- bindService: (OFString*)service
       onNode: (OFString*)node
   withFamily: (int)family;
- listenWithBackLog: (int)backlog;
- listen;
- (OFSocket*)accept;
- enableKeepAlives: (BOOL)enable;
- close;
@end







<
<
<
<
<
<
<
<
<
<
<

51
52
53
54
55
56
57











58
 */
+ socket;

/**
 * Enables/disables non-blocking I/O.
 */
- setBlocking: (BOOL)enable;











@end

Modified src/OFSocket.m from [58e9bceec8] to [90f67dc16d].

108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160

	if (ioctlsocket(sock, FIONBIO, &v) == SOCKET_ERROR)
		@throw [OFSetOptionFailedException newWithClass: isa];
#endif

	return self;
}

- connectToService: (OFString*)service
	    onNode: (OFString*)node
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- bindService: (OFString*)service
       onNode: (OFString*)node
   withFamily: (int)family
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- listenWithBackLog: (int)backlog
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- listen
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- (OFSocket*)accept
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- enableKeepAlives: (BOOL)enable
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- close
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}
@end







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

108
109
110
111
112
113
114













































115

	if (ioctlsocket(sock, FIONBIO, &v) == SOCKET_ERROR)
		@throw [OFSetOptionFailedException newWithClass: isa];
#endif

	return self;
}













































@end

Modified src/OFTCPSocket.h from [fd6abf078a] to [afa9fb265e].

49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
 */
- listen;

/**
 * Accept an incoming connection.
 * \return An autoreleased OFTCPSocket for the accepted connection.
 */
- (OFSocket*)accept;

/**
 * Enable or disable keep alives for the connection.
 */
- enableKeepAlives: (BOOL)enable;

/**
 * Closes the socket.
 */
- close;
@end







|





<
<
<
<
<

49
50
51
52
53
54
55
56
57
58
59
60
61





62
 */
- listen;

/**
 * Accept an incoming connection.
 * \return An autoreleased OFTCPSocket for the accepted connection.
 */
- (OFTCPSocket*)accept;

/**
 * Enable or disable keep alives for the connection.
 */
- enableKeepAlives: (BOOL)enable;





@end

Modified src/OFTCPSocket.m from [b8414e989f] to [e5e0123628].

310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
	if (listen(sock, 5) == -1)
		@throw [OFListenFailedException newWithClass: isa
						     backLog: 5];

	return self;
}

- (OFSocket*)accept
{
	OFTCPSocket *newsock;
	struct sockaddr *addr;
	socklen_t addrlen;
	int s;

	newsock = [OFTCPSocket socket];







|







310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
	if (listen(sock, 5) == -1)
		@throw [OFListenFailedException newWithClass: isa
						     backLog: 5];

	return self;
}

- (OFTCPSocket*)accept
{
	OFTCPSocket *newsock;
	struct sockaddr *addr;
	socklen_t addrlen;
	int s;

	newsock = [OFTCPSocket socket];

Modified tests/OFTCPSocket.m from [90a6cf5f0f] to [6b65fc55ca].

25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

static OFString *module = @"OFTCPSocket";

void
tcpsocket_tests()
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFSocket *server, *client = nil, *accepted;
	OFString *service, *msg;
	uint16_t port;
	char buf[6];

	srand(time(NULL));
	port = (uint16_t)rand();
	if (port < 1024)







|







25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

static OFString *module = @"OFTCPSocket";

void
tcpsocket_tests()
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFTCPSocket *server, *client = nil, *accepted;
	OFString *service, *msg;
	uint16_t port;
	char buf[6];

	srand(time(NULL));
	port = (uint16_t)rand();
	if (port < 1024)