Overview
Comment: | OFSCTPSocket: Use a dictionary for message info
This is more extensible. Without this, extending it later would result |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | sctp |
Files: | files | file ages | folders |
SHA3-256: |
0fd2b1b4c8e3bd75ee619df563752d90 |
User & Date: | js on 2024-05-04 20:05:40 |
Other Links: | branch diff | manifest | tags |
Context
2024-05-04
| ||
20:06 | Add support for SCTP sockets check-in: fef7240652 user: js tags: trunk | |
20:05 | OFSCTPSocket: Use a dictionary for message info Closed-Leaf check-in: 0fd2b1b4c8 user: js tags: sctp | |
2024-05-01
| ||
23:23 | OFSCTPSocket: Rename packet to message check-in: 816c13da9b user: js tags: sctp | |
Changes
Modified src/OFRunLoop+Private.h from [a9ea36d376] to [80e1bfb64f].
︙ | |||
134 135 136 137 138 139 140 | 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | - - - + | mode: (OFRunLoopMode)mode # ifdef OF_HAVE_BLOCKS block: (nullable OFSCTPSocketAsyncReceiveBlock)block # endif delegate: (nullable id <OFSCTPSocketDelegate>)delegate; + (void)of_addAsyncSendForSCTPSocket: (OFSCTPSocket *)socket data: (OFData *)data |
Modified src/OFRunLoop.m from [0a75a2f08b] to [f56fb160b7].
︙ | |||
218 219 220 221 222 223 224 | 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | - - - + | @interface OFRunLoopSCTPSendQueueItem: OFRunLoopQueueItem { @public # ifdef OF_HAVE_BLOCKS OFSCTPSocketAsyncSendDataBlock _block; # endif OFData *_data; |
︙ | |||
1036 1037 1038 1039 1040 1041 1042 | 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 | - - - + - - + - - + - - + + - - - + - | @end # ifdef OF_HAVE_SCTP @implementation OFRunLoopSCTPReceiveQueueItem - (bool)handleObject: (id)object { size_t length; |
︙ | |||
1093 1094 1095 1096 1097 1098 1099 | 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 | - - + - - - + + - - + - | { id exception = nil; OFData *newData, *oldData; @try { [object sendBuffer: _data.items length: _data.count * _data.itemSize |
︙ | |||
1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 | 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 | + | - (void)dealloc { [_data release]; # ifdef OF_HAVE_BLOCKS [_block release]; # endif [_info release]; [super dealloc]; } @end # endif #endif |
︙ | |||
1482 1483 1484 1485 1486 1487 1488 | 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 | - - - + - - + - | queueItem->_length = length; QUEUE_ITEM } + (void)of_addAsyncSendForSCTPSocket: (OFSCTPSocket *)sock data: (OFData *)data |
︙ |
Modified src/OFSCTPSocket.h from [2e3d49a6fe] to [48237f617c].
︙ | |||
20 21 22 23 24 25 26 27 28 29 30 | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | + - + + + + + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + - - + + | #import "OFSequencedPacketSocket.h" #import "OFRunLoop.h" OF_ASSUME_NONNULL_BEGIN /** @file */ @class OFDictionary OF_GENERIC(KeyType, ObjectType); @class OFSCTPSocket; @class OFString; /** |
︙ | |||
92 93 94 95 96 97 98 | 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | - - - + - - - + - - - + - - - + | /** * @brief This method is called when a message has been received. * * @param socket The SCTP socket which received a message * @param buffer The buffer the message has been written to * @param length The length of the message |
︙ | |||
234 235 236 237 238 239 240 | 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | - - - + - - + + - - - + + - - + + - - + + - - + + | * @brief Receives a message for the specified stream ID and stores it into the * specified buffer. * * If the buffer is too small, the message is truncated. * * @param buffer The buffer to write the message to * @param length The length of the buffer |
︙ | |||
320 321 322 323 324 325 326 | 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 | - - - + - - - + - - - + - + - - - - - - + - - - + - - - + - - - + - - - + - - - + | #endif /** * @brief Sends the specified message on the specified stream. * * @param buffer The buffer to send as a message * @param length The length of the buffer |
Modified src/OFSCTPSocket.m from [908828903c] to [4453ea5c07].
︙ | |||
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | + + + + + + | #endif #import "OFSCTPSocket.h" #import "OFAsyncIPSocketConnector.h" #import "OFDNSResolver.h" #import "OFData.h" #import "OFDate.h" #import "OFDictionary.h" #import "OFNumber.h" #import "OFRunLoop.h" #import "OFRunLoop+Private.h" #import "OFSocket.h" #import "OFSocket+Private.h" #import "OFString.h" #import "OFThread.h" #import "OFAcceptSocketFailedException.h" #import "OFAlreadyOpenException.h" #import "OFBindIPSocketFailedException.h" #import "OFGetOptionFailedException.h" #import "OFNotOpenException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFSetOptionFailedException.h" #import "OFWriteFailedException.h" const OFSCTPMessageInfoKey OFSCTPStreamID = @"OFSCTPStreamID"; const OFSCTPMessageInfoKey OFSCTPPPID = @"OFSCTPPPID"; const OFSCTPMessageInfoKey OFSCTPUnordered = @"OFSCTPUnordered"; static const OFRunLoopMode connectRunLoopMode = @"OFSCTPSocketConnectRunLoopMode"; @interface OFSCTPSocket () <OFAsyncIPSocketConnecting> @end @interface OFSCTPSocketConnectDelegate: OFObject <OFSCTPSocketDelegate> |
︙ | |||
341 342 343 344 345 346 347 | 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 | - + - - - - - - - + - + - - + + + - - - - + - - - - + - - - - + + + + - - - - + + - - - + + + | return accepted; } #endif - (size_t)receiveIntoBuffer: (void *)buffer length: (size_t)length { |
︙ | |||
451 452 453 454 455 456 457 | 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 | - + - - - + - - + + + + - + | block: block delegate: nil]; } #endif - (void)sendBuffer: (const void *)buffer length: (size_t)length { |
︙ | |||
493 494 495 496 497 498 499 | 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 | - + - - - - + - - - - - - - + - - + - - - - + - - + - - - - + - - + - | if ((size_t)bytesWritten != length) @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length bytesWritten: bytesWritten errNo: 0]; } |
︙ |
Modified tests/OFSCTPSocketTests.m from [4d2bc6e16e] to [749f241e9f].
︙ | |||
30 31 32 33 34 35 36 | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | - + - - + | @implementation OFSCTPSocketTests - (void)testSCTPSocket { OFSCTPSocket *server, *client, *accepted; OFSocketAddress address; char buffer[6]; |
︙ | |||
57 58 59 60 61 62 63 64 65 | 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | + + + + + + + - + - - - - + - - + - - | [client connectToHost: @"127.0.0.1" port: OFSocketAddressIPPort(&address)]; accepted = [server accept]; OTAssertEqualObjects(OFSocketAddressString(accepted.remoteAddress), @"127.0.0.1"); streamID = [OFNumber numberWithUnsignedShort: 1]; PPID = [OFNumber numberWithUnsignedLong: 1234]; unordered = [OFNumber numberWithBool: true]; sendInfo = [OFDictionary dictionaryWithKeysAndObjects: OFSCTPStreamID, streamID, OFSCTPPPID, PPID, OFSCTPUnordered, unordered, nil]; [client sendBuffer: "Hello!" length: 6 |