Differences From Artifact [f996d3c020]:
- File
src/OFSPXSocket.m
— part of check-in
[ccc6a77c55]
at
2022-08-06 14:43:01
on branch trunk
— Reorder node and network of IPX sockets
This is more standard, albeit -[connectToNetwork:node:port:] sounding a
little bit more like you connect to a network rather than a node. (user: js, size: 9439) [annotate] [blame] [check-ins using]
To Artifact [63c27817f9]:
- File
src/OFSPXSocket.m
— part of check-in
[25adea9a23]
at
2022-08-06 21:14:31
on branch trunk
— Don't use struct sockaddr in OFSocketAddress
struct sockaddr can contain a variable length array, which breaks the
union. (user: js, size: 9468) [annotate] [blame] [check-ins using] [more...]
︙ | ︙ | |||
204 205 206 207 208 209 210 | - (bool)of_connectSocketToAddress: (const OFSocketAddress *)address errNo: (int *)errNo { if (_socket == OFInvalidSocketHandle) @throw [OFNotOpenException exceptionWithObject: self]; | | | 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | - (bool)of_connectSocketToAddress: (const OFSocketAddress *)address errNo: (int *)errNo { if (_socket == OFInvalidSocketHandle) @throw [OFNotOpenException exceptionWithObject: self]; if (connect(_socket, (struct sockaddr *)&address->sockaddr, address->length) != 0) { *errNo = OFSocketErrNo(); return false; } return true; } |
︙ | ︙ | |||
322 323 324 325 326 327 328 | #endif if (_socket != OFInvalidSocketHandle) @throw [OFAlreadyConnectedException exceptionWithSocket: self]; address = OFSocketAddressMakeIPX(0, zeroNode, port); | | > | | | | 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 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 | #endif if (_socket != OFInvalidSocketHandle) @throw [OFAlreadyConnectedException exceptionWithSocket: self]; address = OFSocketAddressMakeIPX(0, zeroNode, port); if ((_socket = socket(address.sockaddr.ipx.sipx_family, SOCK_SEQPACKET | SOCK_CLOEXEC, NSPROTO_SPX)) == OFInvalidSocketHandle) @throw [OFBindFailedException exceptionWithPort: port packetType: SPXPacketType socket: self errNo: OFSocketErrNo()]; _canBlock = true; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC) if ((flags = fcntl(_socket, F_GETFD, 0)) != -1) fcntl(_socket, F_SETFD, flags | FD_CLOEXEC); #endif if (bind(_socket, (struct sockaddr *)&address.sockaddr, address.length) != 0) { int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindFailedException exceptionWithPort: port packetType: SPXPacketType socket: self errNo: errNo]; } memset(&address, 0, sizeof(address)); address.family = OFSocketAddressFamilyIPX; address.length = (socklen_t)sizeof(address.sockaddr); if (OFGetSockName(_socket, (struct sockaddr *)&address.sockaddr, &address.length) != 0) { int errNo = OFSocketErrNo(); closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindFailedException exceptionWithPort: port packetType: SPXPacketType socket: self errNo: errNo]; } if (address.sockaddr.ipx.sipx_family != AF_IPX) { closesocket(_socket); _socket = OFInvalidSocketHandle; @throw [OFBindFailedException exceptionWithPort: port packetType: SPXPacketType socket: self errNo: EAFNOSUPPORT]; } return address; } @end |