Changeset 745 for trunk/server/lib/tsocket/tsocket_guide.txt
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
lib/tsocket/tsocket_guide.txt (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/lib/tsocket/tsocket_guide.txt
r414 r745 24 24 =============================== 25 25 26 The tsocket_address represents an socket endpoint genericly.27 As it's like an abstract class it has no specificconstructor.28 The specific constructors are descripted later sections.29 30 There's a function get the string representation of the 31 endpoint for debugging. Callers should not try to parse32 the string! The should use additional methods of the specific 33 tsocket_address implemention to get more details.26 A tsocket_address represents a generic socket endpoint. 27 It behaves like an abstract class, therefore it has no direct constructor. 28 Constructors are described in later sections of this document. 29 30 A function get the string representation of an endpoint for debugging is 31 available but callers SHOULD NOT try to parse this string. To get more 32 details callers should use getter methods of the specific tsocket_address 33 implemention. 34 34 35 35 char *tsocket_address_string(const struct tsocket_address *addr, 36 36 TALLOC_CTX *mem_ctx); 37 37 38 There's a function to create a copy of the tsocket_address.39 This is useful whenbefore doing modifications to a socket38 A function to create a copy of the tsocket_address is also avilable. 39 This is useful before doing modifications to a socket 40 40 via additional methods of the specific tsocket_address implementation. 41 41 … … 48 48 The tdgram_context is like an abstract class for datagram 49 49 based sockets. The interface provides async 'tevent_req' based 50 functions on top functionality is similar to the 51 recvfrom(2)/sendto(2)/close(2) syscalls. 50 functions similar to recvfrom(2)/sendto(2)/close(2) syscalls. 52 51 53 52 The tdgram_recvfrom_send() method can be called to ask for the 54 next available datagram onthe abstracted tdgram_context.53 next available datagram from the abstracted tdgram_context. 55 54 It returns a 'tevent_req' handle, where the caller can register 56 55 a callback with tevent_req_set_callback(). The callback is triggered 57 when a datagram is available or an error happened.56 when a datagram is available or an error occurs. 58 57 59 58 The callback is then supposed to get the result by calling … … 123 122 =============================== 124 123 125 Thetstream_context is like an abstract class for stream124 A tstream_context is like an abstract class for stream 126 125 based sockets. The interface provides async 'tevent_req' based 127 functions on top functionality is similar to the 128 readv(2)/writev(2)/close(2) syscalls. 129 130 The tstream_pending_bytes() function is able to report 131 how much bytes of the incoming stream have arrived 132 but not consumed yet. It returns -1 and sets 'errno' on failure. 133 Otherwise it returns the number of uncomsumed bytes 134 (it can return 0!). 126 functions similar to the readv(2)/writev(2)/close(2) syscalls. 127 128 The tstream_pending_bytes() function is able to report how many bytes of 129 the incoming stream have been received but have not been consumed yet. 130 It returns -1 and sets 'errno' on failure. 131 Otherwise it returns the number of uncomsumed bytes (it can return 0!). 135 132 136 133 ssize_t tstream_pending_bytes(struct tstream_context *stream); 137 134 138 The tstream_readv_send() method can be called to read fora135 The tstream_readv_send() method can be called to read a 139 136 specific amount of bytes from the stream into the buffers 140 137 of the given iovec vector. The caller has to preallocate the buffers … … 144 141 where the caller can register a callback with tevent_req_set_callback(). 145 142 The callback is triggered when all iovec buffers are completely 146 filled with bytes from the socket or an error happened.143 filled with bytes from the socket or an error occurs. 147 144 148 145 The callback is then supposed to get the result by calling 149 146 tstream_readv_recv() on the 'tevent_req'. It returns -1 150 147 and sets '*perrno' to the actual 'errno' on failure. 151 Otherwise it returns the length of the datagram 152 (0 is never returned!). 148 Otherwise it returns the length of the datagram (0 is never returned!). 153 149 154 150 The caller can only have one outstanding tstream_readv_send() … … 166 162 The tstream_writev_send() method can be called to write 167 163 buffers in the given iovec vector into the stream socket. 168 It 's invalid to pass an empty vector.164 It is invalid to pass an empty vector. 169 165 tstream_writev_send() returns a 'tevent_req' handle, 170 166 where the caller can register a callback with tevent_req_set_callback(). … … 190 186 int *perrno); 191 187 192 The tstream_disconnect_send() method should be used to normally188 The tstream_disconnect_send() method should normally be used to 193 189 shutdown/close the abstracted socket. 194 190 … … 209 205 ============================ 210 206 211 In order to make the live easier for callers whichwant to implement207 In order to simplify the job, for callers that want to implement 212 208 a function to receive a full PDU with a single async function pair, 213 there're some helper functions.209 some helper functions are provided. 214 210 215 211 The caller can use the tstream_readv_pdu_send() function … … 217 213 The caller needs to provide a "next_vector" function and a private 218 214 state for this function. The tstream_readv_pdu engine will ask 219 the next_vector function for the next iovec ve tor to be filled.215 the next_vector function for the next iovec vector to be used. 220 216 There's a tstream_readv_send/recv pair for each vector returned 221 217 by the next_vector function. If the next_vector function detects … … 223 219 of the tevent_req (returned by tstream_readv_pdu_send()) is triggered. 224 220 Note: the buffer allocation is completely up to the next_vector function 225 and it 's private state.221 and its private state. 226 222 227 223 See the 'dcerpc_read_ncacn_packet_send/recv' functions in Samba as an … … 245 241 =========================================== 246 242 247 There're some cases where the caller wants doesn't care aboutthe248 order of doing IO on the abstracted sockets.243 In some cases the caller doesn't care about the IO ordering on the 244 abstracted socket. 249 245 (Remember at the low level there's always only one IO in a specific 250 246 direction allowed, only one tdgram_sendto_send() at a time). 251 247 252 There're some helpers using 'tevent_queue' to make it easier 253 for callers. The functions just get a 'queue' argument 254 and serialize theoperations.248 Some helpers that use 'tevent_queue' are avilable to simplify handling 249 multiple IO requests. The functions just get a 'queue' argument and 250 internally serialize all operations. 255 251 256 252 struct tevent_req *tdgram_sendto_queue_send(TALLOC_CTX *mem_ctx, … … 296 292 (dns names are not allowed!). But it's valid to pass NULL, 297 293 which gets mapped to "0.0.0.0" or "::". 298 It return -1 and seterrno on error. Otherwise it returns 0.294 It returns -1 and sets errno on error. Otherwise it returns 0. 299 295 300 296 int tsocket_address_inet_from_strings(TALLOC_CTX *mem_ctx, … … 343 339 you can use the tsocket_address_unix_path() function. 344 340 It will return NULL and set errno to EINVAL if the tsocket_address 345 doesn't represent a nunix domain endpoint path.341 doesn't represent a unix domain endpoint path. 346 342 347 343 char *tsocket_address_unix_path(const struct tsocket_address *addr, … … 372 368 struct tdgram_context **dgram); 373 369 374 You can use tstream_inet_tcp_connect_send to async 370 You can use tstream_inet_tcp_connect_send to asynchronously 375 371 connect to a remote ipv4 or ipv6 TCP endpoint and create a 376 372 tstream_context for the stream based communication. "local_address" has to be … … 398 394 struct tstream_context **stream); 399 395 400 You can use tstream_unix_connect_send to async 396 You can use tstream_unix_connect_send to asynchronously 401 397 connect to a unix domain endpoint and create a 402 398 tstream_context for the stream based communication. … … 439 435 for that. This should only be used if really needed, because of 440 436 already existing fixed APIs. Only AF_INET, AF_INET6 and AF_UNIX 441 sockets are allowed. The function returns -1 and set errno on error.437 sockets are allowed. The function returns -1 and sets errno on error. 442 438 Otherwise it returns 0. 443 439
Note:
See TracChangeset
for help on using the changeset viewer.
