ObjFW
Loading...
Searching...
No Matches
OFAsyncIPSocketConnector.h
1/*
2 * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im>
3 *
4 * All rights reserved.
5 *
6 * This file is part of ObjFW. It may be distributed under the terms of the
7 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
8 * the packaging of this file.
9 *
10 * Alternatively, it may be distributed under the terms of the GNU General
11 * Public License, either version 2 or 3, which can be found in the file
12 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
13 * file.
14 */
15
16#import "OFDNSResolver.h"
17#import "OFRunLoop.h"
18#import "OFRunLoop+Private.h"
19
20OF_ASSUME_NONNULL_BEGIN
21
22@protocol OFAsyncIPSocketConnecting
23- (bool)of_createSocketForAddress: (const OFSocketAddress *)address
24 errNo: (int *)errNo;
25- (bool)of_connectSocketToAddress: (const OFSocketAddress *)address
26 errNo: (int *)errNo;
27- (void)of_closeSocket;
28@end
29
30@interface OFAsyncIPSocketConnector: OFObject <OFRunLoopConnectDelegate,
31 OFDNSResolverHostDelegate>
32{
33 id _socket;
34 OFString *_host;
35 uint16_t _port;
36 id _Nullable _delegate;
37 id _Nullable _block;
38 id _Nullable _exception;
39 OFData *_Nullable _socketAddresses;
40 size_t _socketAddressesIndex;
41}
42
43- (instancetype)initWithSocket: (id)sock
44 host: (OFString *)host
45 port: (uint16_t)port
46 delegate: (nullable id)delegate
47 block: (nullable id)block;
48- (void)didConnect;
49- (void)tryNextAddressWithRunLoopMode: (OFRunLoopMode)runLoopMode;
50- (void)startWithRunLoopMode: (OFRunLoopMode)runLoopMode;
51@end
52
53OF_ASSUME_NONNULL_END
A class for storing constant strings using the @"" literal.
Definition OFConstantString.h:38
A class for storing arbitrary data in an array.
Definition OFData.h:42
The root class for all other classes inside ObjFW.
Definition OFObject.h:688
A class for handling strings.
Definition OFString.h:135
A struct which represents a host / port pair for a socket.
Definition OFSocket.h:182