ObjFW  Check-in [fe6787bc79]

Overview
Comment:Move some stuff from OFSocket to OFTCPSocket.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: fe6787bc796fe729e77822c31e67e081c73b1061667f719368cc969b837d0ebc
User & Date: js on 2010-01-30 13:33:40
Other Links: manifest | tags
Context
2010-01-30
14:14
Fix missing includes and typos. check-in: 35f59c61c6 user: js tags: trunk
13:33
Move some stuff from OFSocket to OFTCPSocket. check-in: fe6787bc79 user: js tags: trunk
12:46
Change -[retainCount] back to size_t and cast, so we keep the old API. check-in: 2cb37ce407 user: js tags: trunk
Changes

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
 * Copyright (c) 2008 - 2009
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

/*
 * Headers for UNIX systems
 */
#ifndef _WIN32
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#endif

#import "OFStream.h"

/*
 * Headers for Win32
 *
 * These must be imported after objc/objc.h and thus OFObject!
 */
#ifdef _WIN32
#define _WIN32_WINNT 0x0501
#include <winsock2.h>
#include <ws2tcpip.h>
#endif

/**
 * The OFTCPSocket class provides functions to create and use sockets.
 */
@interface OFSocket: OFStream
{
#ifndef _WIN32
	int		sock;
#else
	SOCKET		sock;
#endif
	struct sockaddr	*saddr;
	socklen_t	saddr_len;
	BOOL		eos;
}

/**
 * \return A new autoreleased OFTCPSocket
 */
+ socket;

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











<
<
<
<
<
<
<
<
<


<
<
<
<
<

|
|
<












<
<













1
2
3
4
5
6
7
8
9
10
11









12
13





14
15
16

17
18
19
20
21
22
23
24
25
26
27
28


29
30
31
32
33
34
35
36
37
38
39
40
41
/*
 * Copyright (c) 2008 - 2009
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */










#import "OFStream.h"






#ifdef _WIN32
# define _WIN32_WINNT 0x0501
# include <winsock2.h>

#endif

/**
 * The OFTCPSocket class provides functions to create and use sockets.
 */
@interface OFSocket: OFStream
{
#ifndef _WIN32
	int		sock;
#else
	SOCKET		sock;
#endif


	BOOL		eos;
}

/**
 * \return A new autoreleased OFTCPSocket
 */
+ socket;

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

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

36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#endif

+ socket
{
	return [[[self alloc] init] autorelease];
}

- init
{
	self = [super init];

	sock = INVALID_SOCKET;
	saddr = NULL;

	return self;
}

- (BOOL)atEndOfStreamWithoutCache
{
	return eos;
}

- (size_t)readNBytesWithoutCache: (size_t)size
		      intoBuffer: (char*)buf







<
<
<
<
<
<
<
<
<
<







36
37
38
39
40
41
42










43
44
45
46
47
48
49
#endif

+ socket
{
	return [[[self alloc] init] autorelease];
}











- (BOOL)atEndOfStreamWithoutCache
{
	return eos;
}

- (size_t)readNBytesWithoutCache: (size_t)size
		      intoBuffer: (char*)buf

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

1
2
3
4
5
6
7
8
9
10
11






12




13
14
15
16
17
18
19





20
21
22
23
24
25
26
/*
 * Copyright (c) 2008 - 2009
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */







#import "OFSocket.h"





@class OFString;

/**
 * The OFTCPSocket class provides functions to create and use sockets.
 */
@interface OFTCPSocket: OFSocket {}





/**
 * Connect the OFTCPSocket to the specified destination.
 *
 * \param service The service on the node to connect to
 * \param node The node to connect to
 */
- connectToService: (OFString*)service











>
>
>
>
>
>

>
>
>
>






|
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
 * Copyright (c) 2008 - 2009
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#ifndef _WIN32
# include <sys/types.h>
# include <sys/socket.h>
# include <netdb.h>
#endif

#import "OFSocket.h"

#ifdef _WIN32
# include <ws2tcpip.h>
#endif

@class OFString;

/**
 * The OFTCPSocket class provides functions to create and use sockets.
 */
@interface OFTCPSocket: OFSocket
{
	struct sockaddr	*saddr;
	socklen_t	saddr_len;
}

/**
 * Connect the OFTCPSocket to the specified destination.
 *
 * \param service The service on the node to connect to
 * \param node The node to connect to
 */
- connectToService: (OFString*)service

Modified src/OFTCPSocket.m from [e5e0123628] to [5ad68e30bb].

39
40
41
42
43
44
45










46
47
48
49
50
51
52
#if defined(OF_THREADS) && !defined(HAVE_THREADSAFE_GETADDRINFO)
+ (void)initialize
{
	if (self == [OFTCPSocket class])
		mutex = [[OFMutex alloc] init];
}
#endif











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

	[super dealloc];







>
>
>
>
>
>
>
>
>
>







39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#if defined(OF_THREADS) && !defined(HAVE_THREADSAFE_GETADDRINFO)
+ (void)initialize
{
	if (self == [OFTCPSocket class])
		mutex = [[OFMutex alloc] init];
}
#endif

- init
{
	self = [super init];

	sock = INVALID_SOCKET;
	saddr = NULL;

	return self;
}

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

	[super dealloc];