Differences From Artifact [2a7d7dd320]:
- File
src/OFUDPSocket.h
— part of check-in
[fb590316ba]
at
2014-01-30 12:26:12
on branch trunk
— Rename +[UDPSocket hostForAddress:port:]
It is now called +[getHost:andPort:forAddress:]. This makes it much
clearer from the selector alone what it actually does. (user: js, size: 4676) [annotate] [blame] [check-ins using]
To Artifact [b1471e0ef4]:
- File src/OFUDPSocket.h — part of check-in [ff3c507941] at 2014-01-30 22:02:07 on branch trunk — OFUDPSocket: Add async resolve / receive (user: js, size: 8754) [annotate] [blame] [check-ins using]
︙ | |||
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 17 18 19 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 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 135 136 137 138 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - + + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | #import "OFObject.h" #import "OFKernelEventObserver.h" #import "socket.h" /*! @file */ @class OFUDPSocket; @class OFException; /*! * @brief A struct which represents a host / port pair for a UDP socket. */ typedef struct { struct sockaddr_storage address; socklen_t length; } of_udp_socket_address_t; /*! * @brief A block which is called when the host / port pair for the UDP socket * has been resolved. * * @param host The host that has been resolved * @param port The port of the host / port pair * @param address The address of the resolved host / port pair * @param exception An exception which occurred while resolving or nil on * success */ typedef void (^of_udp_socket_async_resolve_block_t)(OFString *host, uint16_t port, of_udp_socket_address_t address, OFException *exception); /*! * @brief A block which is called when a packet has been received. * * @param socket The UDP which received a packet * @param buffer The buffer the packet has been written to * @param length The length of the packet * @param sender The address of the sender of the packet * @param exception An exception which occurred while receiving or nil on * success * @return A bool whether the same block should be used for the next receive */ typedef bool (^of_udp_socket_async_receive_block_t)(OFUDPSocket *socket, void *buffer, size_t length, of_udp_socket_address_t sender, OFException *exception); /*! * @brief A class which provides functions to create and use UDP sockets. * |
︙ | |||
101 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 | 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | * set to the address of the sender * @return The length of the received datagram */ - (size_t)receiveIntoBuffer: (void*)buffer length: (size_t)length sender: (of_udp_socket_address_t*)sender; /*! * @brief Asynchronously receives a datagram and stores it into the specified * buffer. * * If the buffer is too small, the datagram is truncated. * * @param buffer The buffer to write the datagram to * @param length The length of the buffer * @param target The target on which the selector should be called when the * datagram has been received. If the method returns true, it * will be called again with the same buffer and maximum length * when more datagrams have been received. If you want the next * method in the queue to handle the datagram received next, you * need to return false from the method. * @param selector The selector to call on the target. The signature must be * `bool (OFUDPSocket *socket, void *buffer, size_t length, * of_udp_socket_address_t*, OFException *exception)`. */ - (void)asyncReceiveIntoBuffer: (void*)buffer length: (size_t)length target: (id)target selector: (SEL)selector; #ifdef OF_HAVE_BLOCKS /*! * @brief Asynchronously receives a datagram and stores it into the specified * buffer. * * If the buffer is too small, the datagram is truncated. * * @param buffer The buffer to write the datagram to * @param length The length of the buffer * @param block The block to call when the datagram has been received. If the * block returns true, it will be called again with the same * buffer and maximum length when more datagrams have been * received. If you want the next method in the queue to handle * the datagram received next, you need to return false from the * method. */ - (void)asyncReceiveIntoBuffer: (void*)buffer length: (size_t)length block: (of_udp_socket_async_receive_block_t)block; #endif /*! * @brief Sends the specified datagram to the specified address. * * @param buffer The buffer to send as a datagram * @param length The length of the buffer * @param receiver A pointer to an @ref of_udp_socket_address_t to which the * datagram should be sent */ - (void)sendBuffer: (const void*)buffer length: (size_t)length receiver: (of_udp_socket_address_t*)receiver; /*! * @brief Cancels all pending asyncronous requests on the socket. */ - (void)cancelAsyncRequests; /*! * @brief Closes the socket so that it can neither receive nor send any more * datagrams. */ - (void)close; @end |
︙ |