Differences From Artifact [077e4589a5]:
- File src/OFTCPSocket.h — part of check-in [2b6a12065e] at 2018-12-08 16:53:30 on branch trunk — Separate error methods for async method delegates (user: js, size: 9863) [annotate] [blame] [check-ins using]
To Artifact [e932bc199a]:
- File
src/OFTCPSocket.h
— part of check-in
[064dbe5127]
at
2018-12-11 22:57:46
on branch trunk
— Include an exception in delegate methods
Otherwise, there would be two methods for every operation: One for
success and one for failure. It also makes it easy to forget about
handling failure, so it's better to always pass an optional exception. (user: js, size: 9360) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
60 61 62 63 64 65 66 67 68 69 | */ @protocol OFTCPSocketDelegate <OFStreamDelegate> @optional /*! * @brief A method which is called when a socket connected. * * @param socket The socket which connected */ - (void)socket: (OF_KINDOF(OFTCPSocket *))socket didConnectToHost: (OFString *)host | > > > > | > > > | | < < < < < < < < < < < < < < < < < < < < < < < | 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 | */ @protocol OFTCPSocketDelegate <OFStreamDelegate> @optional /*! * @brief A method which is called when a socket connected. * * @param socket The socket which connected * @param host The host connected to * @param port The port on the host connected to * @param exception An exception that occurred while connecting, or nil on * success */ - (void)socket: (OF_KINDOF(OFTCPSocket *))socket didConnectToHost: (OFString *)host port: (uint16_t)port exception: (nullable id)exception; /*! * @brief A method which is called when a socket accepted a connection. * * @param socket The socket which accepted the connection * @param acceptedSocket The socket which has been accepted * @param exception An exception that occurred while accepting, or nil on * success * @return A bool whether to accept the next incoming connection */ - (bool)socket: (OF_KINDOF(OFTCPSocket *))socket didAcceptSocket: (OF_KINDOF(OFTCPSocket *))acceptedSocket exception: (nullable id)exception; @end /*! * @class OFTCPSocket OFTCPSocket.h ObjFW/OFTCPSocket.h * * @brief A class which provides methods to create and use TCP sockets. * |
︙ | ︙ |