ObjFW
Loading...
Searching...
No Matches
OFSCTPSocket.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
21#import "OFRunLoop.h"
22
23OF_ASSUME_NONNULL_BEGIN
24
27@class OFDictionary OF_GENERIC(KeyType, ObjectType);
28@class OFSCTPSocket;
29@class OFString;
30
41
47
48#ifdef __cplusplus
49extern "C" {
50#endif
57
64
71#ifdef __cplusplus
72}
73#endif
74
75#ifdef OF_HAVE_BLOCKS
86 OFString *host, uint16_t port, id _Nullable exception);
87
100 void *buffer, size_t length, OFSCTPMessageInfo _Nullable info,
101 id _Nullable exception);
102
113typedef OFData *_Nullable (^OFSCTPSocketDataSentHandler)(OFSCTPSocket *socket,
114 OFData *data, OFSCTPMessageInfo _Nullable info, id _Nullable exception);
115#endif
116
122@protocol OFSCTPSocketDelegate <OFSequencedPacketSocketDelegate>
123@optional
133- (void)socket: (OFSCTPSocket *)socket
134 didConnectToHost: (OFString *)host
135 port: (uint16_t)port
136 exception: (nullable id)exception;
137
149- (bool)socket: (OFSCTPSocket *)socket
150 didReceiveIntoBuffer: (void *)buffer
151 length: (size_t)length
152 info: (nullable OFSCTPMessageInfo)info
153 exception: (nullable id)exception;
154
164- (nullable OFData *)socket: (OFSCTPSocket *)socket
165 didSendData: (OFData *)data
166 info: (nullable OFSCTPMessageInfo)info
167 exception: (nullable id)exception;
168@end
169
180{
181 OF_RESERVE_IVARS(OFSCTPSocket, 4)
182}
183
191@property (nonatomic) bool canDelaySendingMessages;
192
199@property OF_NULLABLE_PROPERTY (assign, nonatomic)
200 id <OFSCTPSocketDelegate> delegate;
201
210- (void)connectToHost: (OFString *)host port: (uint16_t)port;
211
218- (void)asyncConnectToHost: (OFString *)host port: (uint16_t)port;
219
227- (void)asyncConnectToHost: (OFString *)host
228 port: (uint16_t)port
229 runLoopMode: (OFRunLoopMode)runLoopMode;
230
231#ifdef OF_HAVE_BLOCKS
240- (void)asyncConnectToHost: (OFString *)host
241 port: (uint16_t)port
242 handler: (OFSCTPSocketConnectedHandler)handler;
243
253- (void)asyncConnectToHost: (OFString *)host
254 port: (uint16_t)port
255 runLoopMode: (OFRunLoopMode)runLoopMode
256 handler: (OFSCTPSocketConnectedHandler)handler;
257#endif
258
270- (OFSocketAddress)bindToHost: (OFString *)host port: (uint16_t)port;
271
285- (size_t)receiveIntoBuffer: (void *)buffer
286 length: (size_t)length
287 info: (__autoreleasing _Nullable OFSCTPMessageInfo
288 *_Nullable)info;
289
299- (void)asyncReceiveWithInfoIntoBuffer: (void *)buffer
300 length: (size_t)length;
301
313- (void)asyncReceiveWithInfoIntoBuffer: (void *)buffer
314 length: (size_t)length
315 runLoopMode: (OFRunLoopMode)runLoopMode;
316
317#ifdef OF_HAVE_BLOCKS
333- (void)
334 asyncReceiveWithInfoIntoBuffer: (void *)buffer
335 length: (size_t)length
336 handler: (OFSCTPSocketMessageReceivedHandler)handler;
337
355- (void)
356 asyncReceiveWithInfoIntoBuffer: (void *)buffer
357 length: (size_t)length
358 runLoopMode: (OFRunLoopMode)runLoopMode
359 handler: (OFSCTPSocketMessageReceivedHandler)handler;
360#endif
361
371- (void)sendBuffer: (const void *)buffer
372 length: (size_t)length
373 info: (nullable OFSCTPMessageInfo)info;
374
381- (void)asyncSendData: (OFData *)data info: (nullable OFSCTPMessageInfo)info;
382
391- (void)asyncSendData: (OFData *)data
392 info: (nullable OFSCTPMessageInfo)info
393 runLoopMode: (OFRunLoopMode)runLoopMode;
394
395#ifdef OF_HAVE_BLOCKS
405- (void)asyncSendData: (OFData *)data
406 info: (nullable OFSCTPMessageInfo)info
407 handler: (OFSCTPSocketDataSentHandler)handler;
408
420- (void)asyncSendData: (OFData *)data
421 info: (nullable OFSCTPMessageInfo)info
422 runLoopMode: (OFRunLoopMode)runLoopMode
423 handler: (OFSCTPSocketDataSentHandler)handler;
424#endif
425@end
426
427OF_ASSUME_NONNULL_END
OFConstantString * OFSCTPMessageInfoKey
A key for the SCTP message info.
Definition OFSCTPSocket.h:40
const OFSCTPMessageInfoKey OFSCTPStreamID
The SCTP stream ID for which the message was send / received.
Definition OFSCTPSocket.m:61
bool(^ OFSCTPSocketMessageReceivedHandler)(OFSCTPSocket *socket, void *buffer, size_t length, OFSCTPMessageInfo info, id exception)
A handler which is called when a message has been received.
Definition OFSCTPSocket.h:99
OFData *(^ OFSCTPSocketDataSentHandler)(OFSCTPSocket *socket, OFData *data, OFSCTPMessageInfo info, id exception)
A handler which is called when a message has been sent.
Definition OFSCTPSocket.h:113
const OFSCTPMessageInfoKey OFSCTPUnordered
Whether the message is send / received out of order.
Definition OFSCTPSocket.m:63
void(^ OFSCTPSocketConnectedHandler)(OFSCTPSocket *socket, OFString *host, uint16_t port, id exception)
A handler which is called when the socket connected.
Definition OFSCTPSocket.h:85
OFDictionary * OFSCTPMessageInfo
A dictionary mapping keys of type OFSCTPMessageInfoKey to their values.
Definition OFSCTPSocket.h:46
const OFSCTPMessageInfoKey OFSCTPPPID
The Payload Protocol Identifier for the message.
Definition OFSCTPSocket.m:62
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
An abstract class for storing objects in a dictionary.
Definition OFDictionary.h:84
A class which provides methods to create and use SCTP sockets in one-to-one mode.
Definition OFSCTPSocket.h:180
A base class for sequenced packet sockets.
Definition OFSequencedPacketSocket.h:184
A class for handling strings.
Definition OFString.h:143
A struct which represents a host / port pair for a socket.
Definition OFSocket.h:189