ObjFW  Check-in [d92d094980]

Overview
Comment:Document more exceptions
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: d92d094980afd81d796c4d9c553a09c0471f976c0bedd1ec8011b66d94ceb432
User & Date: js on 2022-10-17 23:27:06
Other Links: manifest | tags
Context
2022-10-18
10:10
OFDate: Add encoding attribute to serialization check-in: 0cad644045 user: js tags: trunk
2022-10-17
23:27
Document more exceptions check-in: d92d094980 user: js tags: trunk
18:36
Document more exceptions check-in: 3da26ce4d2 user: js tags: trunk
Changes

Modified src/OFSPXSocket.h from [6e2a8c3475] to [f7b34dfc4b].

156
157
158
159
160
161
162
163
164
165
166
167
168
169

/**
 * @brief Bind the socket to the specified network, node and port.
 *
 * @param port The port (sometimes called socket number) to bind to. 0 means to
 *	       pick one and return it.
 * @return The address on which this socket can be reached
 * @throw OFConnectionFailedException Binding failed
 * @throw OFAlreadyConnectedException The socket is already connected or bound
 */
- (OFSocketAddress)bindToPort: (uint16_t)port;
@end

OF_ASSUME_NONNULL_END







|






156
157
158
159
160
161
162
163
164
165
166
167
168
169

/**
 * @brief Bind the socket to the specified network, node and port.
 *
 * @param port The port (sometimes called socket number) to bind to. 0 means to
 *	       pick one and return it.
 * @return The address on which this socket can be reached
 * @throw OFBindFailedException Binding failed
 * @throw OFAlreadyConnectedException The socket is already connected or bound
 */
- (OFSocketAddress)bindToPort: (uint16_t)port;
@end

OF_ASSUME_NONNULL_END

Modified src/OFStream.h from [2f37969ef7] to [a93512463b].

213
214
215
216
217
218
219


220
221
222
223
224
225
226
@property (readonly, nonatomic) bool hasDataInReadBuffer;

/**
 * @brief Whether the stream can block.
 *
 * By default, a stream can block.
 * On Win32, setting this currently only works for sockets!


 */
@property (nonatomic) bool canBlock;

/**
 * @brief The delegate for asynchronous operations on the stream.
 *
 * @note The delegate is retained for as long as asynchronous operations are







>
>







213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
@property (readonly, nonatomic) bool hasDataInReadBuffer;

/**
 * @brief Whether the stream can block.
 *
 * By default, a stream can block.
 * On Win32, setting this currently only works for sockets!
 *
 * @throw OFSetOptionFailedException The option could not be set
 */
@property (nonatomic) bool canBlock;

/**
 * @brief The delegate for asynchronous operations on the stream.
 *
 * @note The delegate is retained for as long as asynchronous operations are
260
261
262
263
264
265
266


267
268
269
270
271
272
273
 * @warning Only call this when you know that specified amount of data is
 *	    available! Otherwise you will get an exception!
 *
 * @param buffer The buffer into which the data is read
 * @param length The length of the data that should be read.
 *		 The buffer *must* be *at least* this big!
 * @throw OFReadFailedException Reading failed


 * @throw OFNotOpenException The stream is not open
 */
 - (void)readIntoBuffer: (void *)buffer exactLength: (size_t)length;

#ifdef OF_HAVE_SOCKETS
/**
 * @brief Asynchronously reads *at most* `length` bytes from the stream into a







>
>







262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
 * @warning Only call this when you know that specified amount of data is
 *	    available! Otherwise you will get an exception!
 *
 * @param buffer The buffer into which the data is read
 * @param length The length of the data that should be read.
 *		 The buffer *must* be *at least* this big!
 * @throw OFReadFailedException Reading failed
 * @throw OFTruncatedDataException The end of the stream was reached before
 *				   reading the specified amount
 * @throw OFNotOpenException The stream is not open
 */
 - (void)readIntoBuffer: (void *)buffer exactLength: (size_t)length;

#ifdef OF_HAVE_SOCKETS
/**
 * @brief Asynchronously reads *at most* `length` bytes from the stream into a
474
475
476
477
478
479
480


481
482
483
484
485
486
487
488
489
490
491
492


493
494
495
496
497
498
499
500
501
502
503
504


505
506
507
508
509
510
511
512
513
514
515
516


517
518
519
520
521
522
523
524
525
526
527
528


529
530
531
532
533
534
535
536
537
538
539
540


541
542
543
544
545
546
547
548
549
550
551
552


553
554
555
556
557
558
559
560
561
562
563
564


565
566
567
568
569
570
571
572
573
574
575
576


577
578
579
580
581
582
583
584
585
586
587
588


589
590
591
592
593
594
595
596
597
598
599
600


601
602
603
604
605
606
607
608
609
610
611
612
613
614


615
616
617
618
619
620
621
622
623
624
625
626
627
628
629


630
631
632
633
634
635
636
 * @brief Reads a uint8_t from the stream.
 *
 * @warning Only call this when you know that enough data is available!
 *	    Otherwise you will get an exception!
 *
 * @return A uint8_t from the stream
 * @throw OFReadFailedException Reading failed


 * @throw OFNotOpenException The stream is not open
 */
- (uint8_t)readInt8;

/**
 * @brief Reads a uint16_t from the stream which is encoded in big endian.
 *
 * @warning Only call this when you know that enough data is available!
 *	    Otherwise you will get an exception!
 *
 * @return A uint16_t from the stream in native endianess
 * @throw OFReadFailedException Reading failed


 * @throw OFNotOpenException The stream is not open
 */
- (uint16_t)readBigEndianInt16;

/**
 * @brief Reads a uint32_t from the stream which is encoded in big endian.
 *
 * @warning Only call this when you know that enough data is available!
 *	    Otherwise you will get an exception!
 *
 * @return A uint32_t from the stream in the native endianess
 * @throw OFReadFailedException Reading failed


 * @throw OFNotOpenException The stream is not open
 */
- (uint32_t)readBigEndianInt32;

/**
 * @brief Reads a uint64_t from the stream which is encoded in big endian.
 *
 * @warning Only call this when you know that enough data is available!
 *	    Otherwise you will get an exception!
 *
 * @return A uint64_t from the stream in the native endianess
 * @throw OFReadFailedException Reading failed


 * @throw OFNotOpenException The stream is not open
 */
- (uint64_t)readBigEndianInt64;

/**
 * @brief Reads a float from the stream which is encoded in big endian.
 *
 * @warning Only call this when you know that enough data is available!
 *	    Otherwise you will get an exception!
 *
 * @return A float from the stream in the native endianess
 * @throw OFReadFailedException Reading failed


 * @throw OFNotOpenException The stream is not open
 */
- (float)readBigEndianFloat;

/**
 * @brief Reads a double from the stream which is encoded in big endian.
 *
 * @warning Only call this when you know that enough data is available!
 *	    Otherwise you will get an exception!
 *
 * @return A double from the stream in the native endianess
 * @throw OFReadFailedException Reading failed


 * @throw OFNotOpenException The stream is not open
 */
- (double)readBigEndianDouble;

/**
 * @brief Reads a uint16_t from the stream which is encoded in little endian.
 *
 * @warning Only call this when you know that enough data is available!
 *	    Otherwise you will get an exception!
 *
 * @return A uint16_t from the stream in native endianess
 * @throw OFReadFailedException Reading failed


 * @throw OFNotOpenException The stream is not open
 */
- (uint16_t)readLittleEndianInt16;

/**
 * @brief Reads a uint32_t from the stream which is encoded in little endian.
 *
 * @warning Only call this when you know that enough data is available!
 *	    Otherwise you will get an exception!
 *
 * @return A uint32_t from the stream in the native endianess
 * @throw OFReadFailedException Reading failed


 * @throw OFNotOpenException The stream is not open
 */
- (uint32_t)readLittleEndianInt32;

/**
 * @brief Reads a uint64_t from the stream which is encoded in little endian.
 *
 * @warning Only call this when you know that enough data is available!
 *	    Otherwise you will get an exception!
 *
 * @return A uint64_t from the stream in the native endianess
 * @throw OFReadFailedException Reading failed


 * @throw OFNotOpenException The stream is not open
 */
- (uint64_t)readLittleEndianInt64;

/**
 * @brief Reads a float from the stream which is encoded in little endian.
 *
 * @warning Only call this when you know that enough data is available!
 *	    Otherwise you will get an exception!
 *
 * @return A float from the stream in the native endianess
 * @throw OFReadFailedException Reading failed


 * @throw OFNotOpenException The stream is not open
 */
- (float)readLittleEndianFloat;

/**
 * @brief Reads a double from the stream which is encoded in little endian.
 *
 * @warning Only call this when you know that enough data is available!
 *	    Otherwise you will get an exception!
 *
 * @return A double from the stream in the native endianess
 * @throw OFReadFailedException Reading failed


 * @throw OFNotOpenException The stream is not open
 */
- (double)readLittleEndianDouble;

/**
 * @brief Reads the specified number of items with an item size of 1 from the
 *	  stream and returns them as OFData.
 *
 * @warning Only call this when you know that enough data is available!
 *	    Otherwise you will get an exception!
 *
 * @param count The number of items to read
 * @return OFData with count items.
 * @throw OFReadFailedException Reading failed


 * @throw OFNotOpenException The stream is not open
 */
- (OFData *)readDataWithCount: (size_t)count;

/**
 * @brief Reads the specified number of items with the specified item size from
 *	  the stream and returns them as OFData.
 *
 * @warning Only call this when you know that enough data is available!
 *	    Otherwise you will get an exception!
 *
 * @param itemSize The size of each item
 * @param count The number of items to read
 * @return OFData with count items.
 * @throw OFReadFailedException Reading failed


 * @throw OFNotOpenException The stream is not open
 */
- (OFData *)readDataWithItemSize: (size_t)itemSize count: (size_t)count;

/**
 * @brief Returns OFData with all the remaining data of the stream.
 *







>
>












>
>












>
>












>
>












>
>












>
>












>
>












>
>












>
>












>
>












>
>














>
>















>
>







478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
 * @brief Reads a uint8_t from the stream.
 *
 * @warning Only call this when you know that enough data is available!
 *	    Otherwise you will get an exception!
 *
 * @return A uint8_t from the stream
 * @throw OFReadFailedException Reading failed
 * @throw OFTruncatedDataException The end of the stream was reached before
 *				   reading enough bytes
 * @throw OFNotOpenException The stream is not open
 */
- (uint8_t)readInt8;

/**
 * @brief Reads a uint16_t from the stream which is encoded in big endian.
 *
 * @warning Only call this when you know that enough data is available!
 *	    Otherwise you will get an exception!
 *
 * @return A uint16_t from the stream in native endianess
 * @throw OFReadFailedException Reading failed
 * @throw OFTruncatedDataException The end of the stream was reached before
 *				   reading enough bytes
 * @throw OFNotOpenException The stream is not open
 */
- (uint16_t)readBigEndianInt16;

/**
 * @brief Reads a uint32_t from the stream which is encoded in big endian.
 *
 * @warning Only call this when you know that enough data is available!
 *	    Otherwise you will get an exception!
 *
 * @return A uint32_t from the stream in the native endianess
 * @throw OFReadFailedException Reading failed
 * @throw OFTruncatedDataException The end of the stream was reached before
 *				   reading enough bytes
 * @throw OFNotOpenException The stream is not open
 */
- (uint32_t)readBigEndianInt32;

/**
 * @brief Reads a uint64_t from the stream which is encoded in big endian.
 *
 * @warning Only call this when you know that enough data is available!
 *	    Otherwise you will get an exception!
 *
 * @return A uint64_t from the stream in the native endianess
 * @throw OFReadFailedException Reading failed
 * @throw OFTruncatedDataException The end of the stream was reached before
 *				   reading enough bytes
 * @throw OFNotOpenException The stream is not open
 */
- (uint64_t)readBigEndianInt64;

/**
 * @brief Reads a float from the stream which is encoded in big endian.
 *
 * @warning Only call this when you know that enough data is available!
 *	    Otherwise you will get an exception!
 *
 * @return A float from the stream in the native endianess
 * @throw OFReadFailedException Reading failed
 * @throw OFTruncatedDataException The end of the stream was reached before
 *				   reading enough bytes
 * @throw OFNotOpenException The stream is not open
 */
- (float)readBigEndianFloat;

/**
 * @brief Reads a double from the stream which is encoded in big endian.
 *
 * @warning Only call this when you know that enough data is available!
 *	    Otherwise you will get an exception!
 *
 * @return A double from the stream in the native endianess
 * @throw OFReadFailedException Reading failed
 * @throw OFTruncatedDataException The end of the stream was reached before
 *				   reading enough bytes
 * @throw OFNotOpenException The stream is not open
 */
- (double)readBigEndianDouble;

/**
 * @brief Reads a uint16_t from the stream which is encoded in little endian.
 *
 * @warning Only call this when you know that enough data is available!
 *	    Otherwise you will get an exception!
 *
 * @return A uint16_t from the stream in native endianess
 * @throw OFReadFailedException Reading failed
 * @throw OFTruncatedDataException The end of the stream was reached before
 *				   reading enough bytes
 * @throw OFNotOpenException The stream is not open
 */
- (uint16_t)readLittleEndianInt16;

/**
 * @brief Reads a uint32_t from the stream which is encoded in little endian.
 *
 * @warning Only call this when you know that enough data is available!
 *	    Otherwise you will get an exception!
 *
 * @return A uint32_t from the stream in the native endianess
 * @throw OFReadFailedException Reading failed
 * @throw OFTruncatedDataException The end of the stream was reached before
 *				   reading enough bytes
 * @throw OFNotOpenException The stream is not open
 */
- (uint32_t)readLittleEndianInt32;

/**
 * @brief Reads a uint64_t from the stream which is encoded in little endian.
 *
 * @warning Only call this when you know that enough data is available!
 *	    Otherwise you will get an exception!
 *
 * @return A uint64_t from the stream in the native endianess
 * @throw OFReadFailedException Reading failed
 * @throw OFTruncatedDataException The end of the stream was reached before
 *				   reading enough bytes
 * @throw OFNotOpenException The stream is not open
 */
- (uint64_t)readLittleEndianInt64;

/**
 * @brief Reads a float from the stream which is encoded in little endian.
 *
 * @warning Only call this when you know that enough data is available!
 *	    Otherwise you will get an exception!
 *
 * @return A float from the stream in the native endianess
 * @throw OFReadFailedException Reading failed
 * @throw OFTruncatedDataException The end of the stream was reached before
 *				   reading enough bytes
 * @throw OFNotOpenException The stream is not open
 */
- (float)readLittleEndianFloat;

/**
 * @brief Reads a double from the stream which is encoded in little endian.
 *
 * @warning Only call this when you know that enough data is available!
 *	    Otherwise you will get an exception!
 *
 * @return A double from the stream in the native endianess
 * @throw OFReadFailedException Reading failed
 * @throw OFTruncatedDataException The end of the stream was reached before
 *				   reading enough bytes
 * @throw OFNotOpenException The stream is not open
 */
- (double)readLittleEndianDouble;

/**
 * @brief Reads the specified number of items with an item size of 1 from the
 *	  stream and returns them as OFData.
 *
 * @warning Only call this when you know that enough data is available!
 *	    Otherwise you will get an exception!
 *
 * @param count The number of items to read
 * @return OFData with count items.
 * @throw OFReadFailedException Reading failed
 * @throw OFTruncatedDataException The end of the stream was reached before
 *				   reading enough bytes
 * @throw OFNotOpenException The stream is not open
 */
- (OFData *)readDataWithCount: (size_t)count;

/**
 * @brief Reads the specified number of items with the specified item size from
 *	  the stream and returns them as OFData.
 *
 * @warning Only call this when you know that enough data is available!
 *	    Otherwise you will get an exception!
 *
 * @param itemSize The size of each item
 * @param count The number of items to read
 * @return OFData with count items.
 * @throw OFReadFailedException Reading failed
 * @throw OFTruncatedDataException The end of the stream was reached before
 *				   reading enough bytes
 * @throw OFNotOpenException The stream is not open
 */
- (OFData *)readDataWithItemSize: (size_t)itemSize count: (size_t)count;

/**
 * @brief Returns OFData with all the remaining data of the stream.
 *
653
654
655
656
657
658
659


660
661
662
663
664
665
666
 *	    Otherwise you will get an exception!
 *
 * @param length The length (in bytes) of the string to read from the stream
 * @return A string with the specified length
 * @throw OFReadFailedException Reading failed
 * @throw OFInvalidEncodingException The string read from the stream has
 *				     invalid encoding


 * @throw OFNotOpenException The stream is not open
 */
- (OFString *)readStringWithLength: (size_t)length;

/**
 * @brief Reads a string with the specified encoding and length from the stream.
 *







>
>







683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
 *	    Otherwise you will get an exception!
 *
 * @param length The length (in bytes) of the string to read from the stream
 * @return A string with the specified length
 * @throw OFReadFailedException Reading failed
 * @throw OFInvalidEncodingException The string read from the stream has
 *				     invalid encoding
 * @throw OFTruncatedDataException The end of the stream was reached before
 *				   reading enough bytes
 * @throw OFNotOpenException The stream is not open
 */
- (OFString *)readStringWithLength: (size_t)length;

/**
 * @brief Reads a string with the specified encoding and length from the stream.
 *
674
675
676
677
678
679
680


681
682
683
684
685
686
687
 *
 * @param encoding The encoding of the string to read from the stream
 * @param length The length (in bytes) of the string to read from the stream
 * @return A string with the specified length
 * @throw OFReadFailedException Reading failed
 * @throw OFInvalidEncodingException The string read from the stream has
 *				     invalid encoding


 * @throw OFNotOpenException The stream is not open
 */
- (OFString *)readStringWithLength: (size_t)length
			  encoding: (OFStringEncoding)encoding;

/**
 * @brief Reads until a newline, `\0` or end of stream occurs.







>
>







706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
 *
 * @param encoding The encoding of the string to read from the stream
 * @param length The length (in bytes) of the string to read from the stream
 * @return A string with the specified length
 * @throw OFReadFailedException Reading failed
 * @throw OFInvalidEncodingException The string read from the stream has
 *				     invalid encoding
 * @throw OFTruncatedDataException The end of the stream was reached before
 *				   reading enough bytes
 * @throw OFNotOpenException The stream is not open
 */
- (OFString *)readStringWithLength: (size_t)length
			  encoding: (OFStringEncoding)encoding;

/**
 * @brief Reads until a newline, `\0` or end of stream occurs.

Modified src/OFStreamSocket.h from [5c1a8b3304] to [310cc8cd98].

76
77
78
79
80
81
82



83
84
85
86
87
88
89
 */
@property (readonly, nonatomic, getter=isListening) bool listening;

/**
 * @brief The remote address.
 *
 * @note This only works for accepted sockets!



 */
@property (readonly, nonatomic) const OFSocketAddress *remoteAddress;

/**
 * @brief The delegate for asynchronous operations on the socket.
 *
 * @note The delegate is retained for as long as asynchronous operations are







>
>
>







76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
 */
@property (readonly, nonatomic, getter=isListening) bool listening;

/**
 * @brief The remote address.
 *
 * @note This only works for accepted sockets!
 *
 * @throw OFNotOpenException The socket is not open
 * @throw OFInvalidArgumentException The socket has no remote address
 */
@property (readonly, nonatomic) const OFSocketAddress *remoteAddress;

/**
 * @brief The delegate for asynchronous operations on the socket.
 *
 * @note The delegate is retained for as long as asynchronous operations are
99
100
101
102
103
104
105


106
107
108
109
110



111
112
113
114
115
116
117


118
119
120
121
122
123
124
 */
+ (instancetype)socket;

/**
 * @brief Listen on the socket.
 *
 * @param backlog Maximum length for the queue of pending connections.


 */
- (void)listenWithBacklog: (int)backlog;

/**
 * @brief Listen on the socket.



 */
- (void)listen;

/**
 * @brief Accept an incoming connection.
 *
 * @return An autoreleased OFStreamSocket for the accepted connection.


 */
- (instancetype)accept;

/**
 * @brief Asynchronously accept an incoming connection.
 */
- (void)asyncAccept;







>
>





>
>
>







>
>







102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
 */
+ (instancetype)socket;

/**
 * @brief Listen on the socket.
 *
 * @param backlog Maximum length for the queue of pending connections.
 * @throw OFListenFailedException Listening failed
 * @throw OFNotOpenException The socket is not open
 */
- (void)listenWithBacklog: (int)backlog;

/**
 * @brief Listen on the socket.
 *
 * @throw OFListenFailedException Listening failed
 * @throw OFNotOpenException The socket is not open
 */
- (void)listen;

/**
 * @brief Accept an incoming connection.
 *
 * @return An autoreleased OFStreamSocket for the accepted connection.
 * @throw OFAcceptFailedException Accepting failed
 * @throw OFNotOpenException The socket is not open
 */
- (instancetype)accept;

/**
 * @brief Asynchronously accept an incoming connection.
 */
- (void)asyncAccept;

Modified src/OFTCPSocket.h from [21cfa24eb5] to [13742bc171].

79
80
81
82
83
84
85



86
87
88
89
90
91
92
93
94
95



96
97
98
99
100
101
102
#endif

#if !defined(OF_WII) && !defined(OF_NINTENDO_3DS)
/**
 * @brief Whether the socket sends keep alives for the connection.
 *
 * @warning This is not available on the Wii or Nintendo 3DS!



 */
@property (nonatomic) bool sendsKeepAlives;
#endif

#ifndef OF_WII
/**
 * @brief Whether sending segments can be delayed. Setting this to `false` sets
 *        TCP_NODELAY on the socket.
 *
 * @warning This is not available on the Wii!



 */
@property (nonatomic) bool canDelaySendingSegments;
#endif

/**
 * @brief The host to use as a SOCKS5 proxy.
 */







>
>
>










>
>
>







79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#endif

#if !defined(OF_WII) && !defined(OF_NINTENDO_3DS)
/**
 * @brief Whether the socket sends keep alives for the connection.
 *
 * @warning This is not available on the Wii or Nintendo 3DS!
 *
 * @throw OFSetOptionFailedException The option could not be set
 * @throw OFGetOptionFailedException The option could not be gotten
 */
@property (nonatomic) bool sendsKeepAlives;
#endif

#ifndef OF_WII
/**
 * @brief Whether sending segments can be delayed. Setting this to `false` sets
 *        TCP_NODELAY on the socket.
 *
 * @warning This is not available on the Wii!
 *
 * @throw OFSetOptionFailedException The option could not be set
 * @throw OFGetOptionFailedException The option could not be gotten
 */
@property (nonatomic) bool canDelaySendingSegments;
#endif

/**
 * @brief The host to use as a SOCKS5 proxy.
 */
146
147
148
149
150
151
152


153
154
155
156
157
158
159
+ (uint16_t)SOCKS5Port;

/**
 * @brief Connects the OFTCPSocket to the specified destination.
 *
 * @param host The host to connect to
 * @param port The port on the host to connect to


 */
- (void)connectToHost: (OFString *)host port: (uint16_t)port;

/**
 * @brief Asynchronously connects the OFTCPSocket to the specified destination.
 *
 * @param host The host to connect to







>
>







152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
+ (uint16_t)SOCKS5Port;

/**
 * @brief Connects the OFTCPSocket to the specified destination.
 *
 * @param host The host to connect to
 * @param port The port on the host to connect to
 * @throw OFConnectionFailedException Connecting failed
 * @throw OFAlreadyConnectedException The socket is already connected or bound
 */
- (void)connectToHost: (OFString *)host port: (uint16_t)port;

/**
 * @brief Asynchronously connects the OFTCPSocket to the specified destination.
 *
 * @param host The host to connect to
202
203
204
205
206
207
208


209
210
211
212
213
 * @brief Binds the socket to the specified host and port.
 *
 * @param host The host to bind to. Use `@"0.0.0.0"` for IPv4 or `@"::"` for
 *	       IPv6 to bind to all.
 * @param port The port to bind to. If the port is 0, an unused port will be
 *	       chosen, which can be obtained using the return value.
 * @return The port the socket was bound to


 */
- (uint16_t)bindToHost: (OFString *)host port: (uint16_t)port;
@end

OF_ASSUME_NONNULL_END







>
>





210
211
212
213
214
215
216
217
218
219
220
221
222
223
 * @brief Binds the socket to the specified host and port.
 *
 * @param host The host to bind to. Use `@"0.0.0.0"` for IPv4 or `@"::"` for
 *	       IPv6 to bind to all.
 * @param port The port to bind to. If the port is 0, an unused port will be
 *	       chosen, which can be obtained using the return value.
 * @return The port the socket was bound to
 * @throw OFBindFailedException Binding failed
 * @throw OFAlreadyConnectedException The socket is already connected or bound
 */
- (uint16_t)bindToHost: (OFString *)host port: (uint16_t)port;
@end

OF_ASSUME_NONNULL_END

Modified src/OFTCPSocket.m from [922c01af3e] to [3962a70e27].

217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
- (void)asyncConnectToHost: (OFString *)host
		      port: (uint16_t)port
	       runLoopMode: (OFRunLoopMode)runLoopMode
{
	void *pool = objc_autoreleasePoolPush();
	id <OFTCPSocketDelegate> delegate;

	if (_socket != OFInvalidSocketHandle)
		@throw [OFAlreadyConnectedException exceptionWithSocket: self];

	if (_SOCKS5Host != nil) {
		delegate = [[[OFTCPSocketSOCKS5Connector alloc]
		    initWithSocket: self
			      host: host
			      port: port
			  delegate: _delegate
#ifdef OF_HAVE_BLOCKS







<
<
<







217
218
219
220
221
222
223



224
225
226
227
228
229
230
- (void)asyncConnectToHost: (OFString *)host
		      port: (uint16_t)port
	       runLoopMode: (OFRunLoopMode)runLoopMode
{
	void *pool = objc_autoreleasePoolPush();
	id <OFTCPSocketDelegate> delegate;




	if (_SOCKS5Host != nil) {
		delegate = [[[OFTCPSocketSOCKS5Connector alloc]
		    initWithSocket: self
			      host: host
			      port: port
			  delegate: _delegate
#ifdef OF_HAVE_BLOCKS
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
		      port: (uint16_t)port
	       runLoopMode: (OFRunLoopMode)runLoopMode
		     block: (OFTCPSocketAsyncConnectBlock)block
{
	void *pool = objc_autoreleasePoolPush();
	id <OFTCPSocketDelegate> delegate = nil;

	if (_socket != OFInvalidSocketHandle)
		@throw [OFAlreadyConnectedException exceptionWithSocket: self];

	if (_SOCKS5Host != nil) {
		delegate = [[[OFTCPSocketSOCKS5Connector alloc]
		    initWithSocket: self
			      host: host
			      port: port
			  delegate: nil
			     block: block] autorelease];







<
<
<







262
263
264
265
266
267
268



269
270
271
272
273
274
275
		      port: (uint16_t)port
	       runLoopMode: (OFRunLoopMode)runLoopMode
		     block: (OFTCPSocketAsyncConnectBlock)block
{
	void *pool = objc_autoreleasePoolPush();
	id <OFTCPSocketDelegate> delegate = nil;




	if (_SOCKS5Host != nil) {
		delegate = [[[OFTCPSocketSOCKS5Connector alloc]
		    initWithSocket: self
			      host: host
			      port: port
			  delegate: nil
			     block: block] autorelease];