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 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 "OFStreamSocket.h"
21#import "OFRunLoop.h"
22
23OF_ASSUME_NONNULL_BEGIN
24
27@class OFTCPSocket;
28@class OFString;
29
30#ifdef OF_HAVE_BLOCKS
37typedef void (^OFTCPSocketAsyncConnectBlock)(id _Nullable exception);
38#endif
39
45@protocol OFTCPSocketDelegate <OFStreamSocketDelegate>
46@optional
56- (void)socket: (OFTCPSocket *)socket
57 didConnectToHost: (OFString *)host
58 port: (uint16_t)port
59 exception: (nullable id)exception;
60@end
61
71{
72 OFString *_Nullable _SOCKS5Host;
73 uint16_t _SOCKS5Port;
74#ifdef OF_WII
75 uint16_t _port;
76#endif
77 OF_RESERVE_IVARS(OFTCPSocket, 4)
78}
79
80#ifdef OF_HAVE_CLASS_PROPERTIES
81@property (class, nullable, copy, nonatomic) OFString *SOCKS5Host;
82@property (class, nonatomic) uint16_t SOCKS5Port;
83#endif
84
85#if !defined(OF_WII) && !defined(OF_NINTENDO_3DS)
94@property (nonatomic) bool sendsKeepAlives;
95#endif
96
97#ifndef OF_WII
107@property (nonatomic) bool canDelaySendingSegments;
108#endif
109
113@property OF_NULLABLE_PROPERTY (copy, nonatomic) OFString *SOCKS5Host;
114
118@property (nonatomic) uint16_t SOCKS5Port;
119
126@property OF_NULLABLE_PROPERTY (assign, nonatomic)
127 id <OFTCPSocketDelegate> delegate;
128
135+ (void)setSOCKS5Host: (nullable OFString *)SOCKS5Host;
136
142+ (nullable OFString *)SOCKS5Host;
143
149+ (void)setSOCKS5Port: (uint16_t)SOCKS5Port;
150
156+ (uint16_t)SOCKS5Port;
157
166- (void)connectToHost: (OFString *)host port: (uint16_t)port;
167
174- (void)asyncConnectToHost: (OFString *)host port: (uint16_t)port;
175
184- (void)asyncConnectToHost: (OFString *)host
185 port: (uint16_t)port
186 runLoopMode: (OFRunLoopMode)runLoopMode;
187
188#ifdef OF_HAVE_BLOCKS
196- (void)asyncConnectToHost: (OFString *)host
197 port: (uint16_t)port
198 block: (OFTCPSocketAsyncConnectBlock)block;
199
209- (void)asyncConnectToHost: (OFString *)host
210 port: (uint16_t)port
211 runLoopMode: (OFRunLoopMode)runLoopMode
212 block: (OFTCPSocketAsyncConnectBlock)block;
213#endif
214
226- (OFSocketAddress)bindToHost: (OFString *)host port: (uint16_t)port;
227@end
228
229OF_ASSUME_NONNULL_END
void(^ OFTCPSocketAsyncConnectBlock)(id exception)
A block which is called when the socket connected.
Definition OFTCPSocket.h:37
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:72
A class for handling strings.
Definition OFString.h:139
A class which provides methods to create and use TCP sockets.
Definition OFTCPSocket.h:71
OFString * SOCKS5Host
The host to use as a SOCKS5 proxy.
Definition OFTCPSocket.h:113
A struct which represents a host / port pair for a socket.
Definition OFSocket.h:186