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 program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License version 3.0 only,
8 * as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13 * version 3.0 for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * version 3.0 along with this program. If not, see
17 * <https://www.gnu.org/licenses/>.
18 */
19
20#import "OFDNSResolver.h"
21#import "OFRunLoop.h"
22#import "OFRunLoop+Private.h"
23
24OF_ASSUME_NONNULL_BEGIN
25
26@protocol OFAsyncIPSocketConnecting
27- (bool)of_createSocketForAddress: (const OFSocketAddress *)address
28 errNo: (int *)errNo;
29- (bool)of_connectSocketToAddress: (const OFSocketAddress *)address
30 errNo: (int *)errNo;
31- (void)of_closeSocket;
32@end
33
34@interface OFAsyncIPSocketConnector: OFObject <OFRunLoopConnectDelegate,
35 OFDNSResolverHostDelegate>
36{
37 id _socket;
38 OFString *_host;
39 uint16_t _port;
40 id _Nullable _delegate;
41 id _Nullable _handler;
42 id _Nullable _exception;
43 OFData *_Nullable _socketAddresses;
44 size_t _socketAddressesIndex;
45}
46
47- (instancetype)initWithSocket: (id)sock
48 host: (OFString *)host
49 port: (uint16_t)port
50 delegate: (nullable id)delegate
51 handler: (nullable id)handler;
52- (void)didConnect;
53- (void)tryNextAddressWithRunLoopMode: (OFRunLoopMode)runLoopMode;
54- (void)startWithRunLoopMode: (OFRunLoopMode)runLoopMode;
55@end
56
57OF_ASSUME_NONNULL_END
A class for storing constant strings using the @"" literal.
Definition OFConstantString.h:42
A class for storing arbitrary data in an array.
Definition OFData.h:46
The root class for all other classes inside ObjFW.
Definition OFObject.h:692
A class for handling strings.
Definition OFString.h:143
A struct which represents a host / port pair for a socket.
Definition OFSocket.h:189