ObjFW
OFTCPSocket.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2021 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 
19 OF_ASSUME_NONNULL_BEGIN
20 
23 @class OFTCPSocket;
24 @class OFString;
25 
26 #ifdef OF_HAVE_BLOCKS
33 typedef void (^of_tcp_socket_async_connect_block_t)(id _Nullable exception);
34 #endif
35 
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)
87 @property (nonatomic) bool sendsKeepAlives;
88 #endif
89 
90 #ifndef OF_WII
97 @property (nonatomic) bool canDelaySendingSegments;
98 #endif
99 
103 @property OF_NULLABLE_PROPERTY (copy, nonatomic) OFString *SOCKS5Host;
104 
108 @property (nonatomic) uint16_t SOCKS5Port;
109 
116 @property OF_NULLABLE_PROPERTY (assign, nonatomic)
118 
125 + (void)setSOCKS5Host: (nullable OFString *)SOCKS5Host;
126 
132 + (nullable OFString *)SOCKS5Host;
133 
139 + (void)setSOCKS5Port: (uint16_t)SOCKS5Port;
140 
146 + (uint16_t)SOCKS5Port;
147 
154 - (void)connectToHost: (OFString *)host port: (uint16_t)port;
155 
162 - (void)asyncConnectToHost: (OFString *)host port: (uint16_t)port;
163 
171 - (void)asyncConnectToHost: (OFString *)host
172  port: (uint16_t)port
173  runLoopMode: (of_run_loop_mode_t)runLoopMode;
174 
175 #ifdef OF_HAVE_BLOCKS
183 - (void)asyncConnectToHost: (OFString *)host
184  port: (uint16_t)port
186 
195 - (void)asyncConnectToHost: (OFString *)host
196  port: (uint16_t)port
197  runLoopMode: (of_run_loop_mode_t)runLoopMode
199 #endif
200 
210 - (uint16_t)bindToHost: (OFString *)host port: (uint16_t)port;
211 @end
212 
213 #ifdef __cplusplus
214 extern "C" {
215 #endif
216 extern Class _Nullable of_tls_socket_class;
217 #ifdef __cplusplus
218 }
219 #endif
220 
221 OF_ASSUME_NONNULL_END
void(^ of_tcp_socket_async_connect_block_t)(id _Nullable exception)
A block which is called when the socket connected.
Definition: OFTCPSocket.h:33
struct objc_object * id
A pointer to any object.
Definition: ObjFWRT.h:90
struct objc_class * Class
A pointer to a class.
Definition: ObjFWRT.h:85
A class for storing constant strings using the @"" literal.
Definition: OFConstantString.h:42
A class which provides methods to create and use stream sockets.
Definition: OFStreamSocket.h:69
A class for handling strings.
Definition: OFString.h:132
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:103
Definition: OFStreamSocket.h:45
Definition: OFTCPSocket.h:41