ObjFW
Loading...
Searching...
No Matches
OFTCPSocket.h
Go to the documentation of this file.
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 "OFStreamSocket.h"
17#import "OFRunLoop.h"
18
19OF_ASSUME_NONNULL_BEGIN
20
23@class OFTCPSocket;
24@class OFString;
25
26#ifdef OF_HAVE_BLOCKS
33typedef void (^OFTCPSocketAsyncConnectBlock)(id _Nullable exception);
34#endif
35
41@protocol OFTCPSocketDelegate <OFStreamSocketDelegate>
42@optional
52- (void)socket: (OFTCPSocket *)socket
53 didConnectToHost: (OFString *)host
54 port: (uint16_t)port
55 exception: (nullable id)exception;
56@end
57
67{
68 OFString *_Nullable _SOCKS5Host;
69 uint16_t _SOCKS5Port;
70#ifdef OF_WII
71 uint16_t _port;
72#endif
73 OF_RESERVE_IVARS(OFTCPSocket, 4)
74}
75
76#ifdef OF_HAVE_CLASS_PROPERTIES
77@property (class, nullable, copy, nonatomic) OFString *SOCKS5Host;
78@property (class, nonatomic) uint16_t SOCKS5Port;
79#endif
80
81#if !defined(OF_WII) && !defined(OF_NINTENDO_3DS)
90@property (nonatomic) bool sendsKeepAlives;
91#endif
92
93#ifndef OF_WII
103@property (nonatomic) bool canDelaySendingSegments;
104#endif
105
109@property OF_NULLABLE_PROPERTY (copy, nonatomic) OFString *SOCKS5Host;
110
114@property (nonatomic) uint16_t SOCKS5Port;
115
122@property OF_NULLABLE_PROPERTY (assign, nonatomic)
123 id <OFTCPSocketDelegate> delegate;
124
131+ (void)setSOCKS5Host: (nullable OFString *)SOCKS5Host;
132
138+ (nullable OFString *)SOCKS5Host;
139
145+ (void)setSOCKS5Port: (uint16_t)SOCKS5Port;
146
152+ (uint16_t)SOCKS5Port;
153
162- (void)connectToHost: (OFString *)host port: (uint16_t)port;
163
170- (void)asyncConnectToHost: (OFString *)host port: (uint16_t)port;
171
180- (void)asyncConnectToHost: (OFString *)host
181 port: (uint16_t)port
182 runLoopMode: (OFRunLoopMode)runLoopMode;
183
184#ifdef OF_HAVE_BLOCKS
192- (void)asyncConnectToHost: (OFString *)host
193 port: (uint16_t)port
194 block: (OFTCPSocketAsyncConnectBlock)block;
195
205- (void)asyncConnectToHost: (OFString *)host
206 port: (uint16_t)port
207 runLoopMode: (OFRunLoopMode)runLoopMode
208 block: (OFTCPSocketAsyncConnectBlock)block;
209#endif
210
222- (OFSocketAddress)bindToHost: (OFString *)host port: (uint16_t)port;
223@end
224
225OF_ASSUME_NONNULL_END
void(^ OFTCPSocketAsyncConnectBlock)(id exception)
A block which is called when the socket connected.
Definition OFTCPSocket.h:33
A class for storing constant strings using the @"" literal.
Definition OFConstantString.h:38
A class which provides methods to create and use stream sockets.
Definition OFStreamSocket.h:68
A class for handling strings.
Definition OFString.h:135
A class which provides methods to create and use TCP sockets.
Definition OFTCPSocket.h:67
OFString * SOCKS5Host
The host to use as a SOCKS5 proxy.
Definition OFTCPSocket.h:109
A struct which represents a host / port pair for a socket.
Definition OFSocket.h:182