ObjFW  Diff

Differences From Artifact [3d03b149bd]:

To Artifact [d5659a0309]:


1
2
3
4
5
6
7
8
9
10
11




12





13
14
15

16

17
18
19
20
21
22
23
/*
 * Copyright (c) 2008 - 2010
 *   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 "OFObject.h"






@class OFSocket;
@class OFTCPSocket;

@class OFDataArray;

@class OFMutableDictionary;

/**
 * \brief A protocol that needs to be implemented by delegates for
 *	  OFSocketObserver.
 */
@protocol OFSocketObserverDelegate











>
>
>
>

>
>
>
>
>



>

>







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
/*
 * Copyright (c) 2008 - 2010
 *   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.
 */

#if !defined(OF_HAVE_POLL) && defined(OF_HAVE_SYS_SELECT_H)
# include <sys/select.h>
#endif

#import "OFObject.h"

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

@class OFSocket;
@class OFTCPSocket;
#ifdef OF_HAVE_POLL
@class OFDataArray;
#endif
@class OFMutableDictionary;

/**
 * \brief A protocol that needs to be implemented by delegates for
 *	  OFSocketObserver.
 */
@protocol OFSocketObserverDelegate
46
47
48
49
50
51
52

53





54
55
56
57
58
59
60

/**
 * \brief A class that can observe multiple sockets at once.
 */
@interface OFSocketObserver: OFObject
{
	OFObject <OFSocketObserverDelegate> *delegate;

	OFDataArray *fds;





	OFMutableDictionary *fdToSocket;
}

#ifdef OF_HAVE_PROPERTIES
@property (retain) OFObject <OFSocketObserverDelegate> *delegate;
#endif








>

>
>
>
>
>







57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77

/**
 * \brief A class that can observe multiple sockets at once.
 */
@interface OFSocketObserver: OFObject
{
	OFObject <OFSocketObserverDelegate> *delegate;
#ifdef OF_HAVE_POLL
	OFDataArray *fds;
#else
	fd_set readfds;
	fd_set writefds;
	int nfds;
#endif
	OFMutableDictionary *fdToSocket;
}

#ifdef OF_HAVE_PROPERTIES
@property (retain) OFObject <OFSocketObserverDelegate> *delegate;
#endif

115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130

131
132
133
134
135
136
137
 *
 * \param sock The socket to remove from observing for writing
 */
- (void)removeSocketToObserveForWriting: (OFSocket*)sock;

/**
 * Observes all sockets and blocks until an event happens on a socket.
 *
 * \return The number of sockets that have pending events
 */
- (int)observe;

/**
 * Observes all sockets until an event happens on a socket or the timeout is
 * reached.
 *

 * \return The number of sockets that have pending events
 */
- (int)observeWithTimeout: (int)timeout;
@end

@interface OFObject (OFSocketObserverDelegate) <OFSocketObserverDelegate>
@end







<
<

|





>
|

|




132
133
134
135
136
137
138


139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
 *
 * \param sock The socket to remove from observing for writing
 */
- (void)removeSocketToObserveForWriting: (OFSocket*)sock;

/**
 * Observes all sockets and blocks until an event happens on a socket.


 */
- (void)observe;

/**
 * Observes all sockets until an event happens on a socket or the timeout is
 * reached.
 *
 * \param timeout The time to wait for an event, in milliseconds
 * \return A boolean whether events occurred during the timeinterval
 */
- (BOOL)observeWithTimeout: (int)timeout;
@end

@interface OFObject (OFSocketObserverDelegate) <OFSocketObserverDelegate>
@end