summaryrefslogtreecommitdiff
path: root/libs/asio/doc/requirements/DatagramSocketService.qbk
blob: dc4865d5ed027ad904e81fc0cb4585783a021e24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
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
164
165
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
[/
 / Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
 /
 / Distributed under the Boost Software License, Version 1.0. (See accompanying
 / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 /]

[section:DatagramSocketService Datagram socket service requirements]

A datagram socket service must meet the requirements for a [link
boost_asio.reference.SocketService socket service], as well as the
additional requirements listed below.

In the table below, `X` denotes a datagram socket service class for protocol
[link boost_asio.reference.Protocol `Protocol`], `a` denotes a value of type
`X`, `b` denotes a value of type `X::implementation_type`, `e` denotes a value
of type `Protocol::endpoint`, `ec` denotes a value of type `error_code`, `f`
denotes a value of type `socket_base::message_flags`, `mb` denotes a value
satisfying [link boost_asio.reference.MutableBufferSequence mutable buffer
sequence] requirements, `rh` denotes a value meeting [link
boost_asio.reference.ReadHandler `ReadHandler`] requirements, `cb` denotes a
value satisfying [link boost_asio.reference.ConstBufferSequence constant
buffer sequence] requirements, and `wh` denotes a value meeting [link
boost_asio.reference.WriteHandler `WriteHandler`] requirements.

[table DatagramSocketService requirements
  [[expression] [return type] [assertion/note\npre/post-condition]]
  [
    [`a.receive(b, mb, f, ec);`]
    [`size_t`]
    [
      pre: `a.is_open(b)`.\n
      \n
      Reads one or more bytes of data from a connected socket `b`.\n
      \n
      The mutable buffer sequence `mb` specifies memory where the data should
      be placed. The operation shall always fill a buffer in the sequence
      completely before proceeding to the next.\n
      \n
      If successful, returns the number of bytes read. Otherwise returns `0`.
    ]
  ]
  [
    [`a.async_receive(b, mb, f, rh);`]
    [`void`]
    [
      pre: `a.is_open(b)`.\n
      \n
      Initiates an asynchronous operation to read one or more bytes of data
      from a connected socket `b`. The operation is performed via the
      `io_service` object `a.get_io_service()` and behaves according to [link
      boost_asio.reference.asynchronous_operations asynchronous operation]
      requirements.\n
      \n
      The mutable buffer sequence `mb` specifies memory where the data should
      be placed. The operation shall always fill a buffer in the sequence
      completely before proceeding to the next.\n
      \n
      The implementation shall maintain one or more copies of `mb` until such
      time as the read operation no longer requires access to the memory
      specified by the buffers in the sequence. The program must ensure the
      memory is valid until:\n
      \n
      [mdash] the last copy of `mb` is destroyed, or\n
      \n
      [mdash] the handler for the asynchronous operation is invoked,\n
      \n
      whichever comes first.\n
      \n
      If the operation completes successfully, the `ReadHandler` object
      `rh` is invoked with the number of bytes transferred. Otherwise it is
      invoked with `0`.
    ]
  ]
  [
    [`a.receive_from(b, mb, e, f, ec);`]
    [`size_t`]
    [
      pre: `a.is_open(b)`.\n
      \n
      Reads one or more bytes of data from an unconnected socket `b`.\n
      \n
      The mutable buffer sequence `mb` specifies memory where the data should
      be placed. The operation shall always fill a buffer in the sequence
      completely before proceeding to the next.\n
      \n
      If successful, returns the number of bytes read. Otherwise returns `0`.
    ]
  ]
  [
    [`a.async_receive_from(b, mb, e, f, rh);`]
    [`void`]
    [
      pre: `a.is_open(b)`.\n
      \n
      Initiates an asynchronous operation to read one or more bytes of data
      from an unconnected socket `b`. The operation is performed via the
      `io_service` object `a.get_io_service()` and behaves according to [link
      boost_asio.reference.asynchronous_operations asynchronous operation]
      requirements.\n
      \n
      The mutable buffer sequence `mb` specifies memory where the data should
      be placed. The operation shall always fill a buffer in the sequence
      completely before proceeding to the next.\n
      \n
      The implementation shall maintain one or more copies of `mb` until such
      time as the read operation no longer requires access to the memory
      specified by the buffers in the sequence. The program must ensure the
      memory is valid until:\n
      \n
      [mdash] the last copy of `mb` is destroyed, or\n
      \n
      [mdash] the handler for the asynchronous operation is invoked,\n
      \n
      whichever comes first.\n
      \n
      The program must ensure the object `e` is valid until the handler
      for the asynchronous operation is invoked.\n
      \n
      If the operation completes successfully, the `ReadHandler` object
      `rh` is invoked with the number of bytes transferred. Otherwise it is
      invoked with `0`.
    ]
  ]
  [
    [`a.send(b, cb, f, ec);`]
    [`size_t`]
    [
      pre: `a.is_open(b)`.\n
      \n
      Writes one or more bytes of data to a connected socket `b`.\n
      \n
      The constant buffer sequence `cb` specifies memory where the data to be
      written is located. The operation shall always write a buffer in the
      sequence completely before proceeding to the next.\n
      \n
      If successful, returns the number of bytes written. Otherwise returns `0`.
    ]
  ]
  [
    [`a.async_send(b, cb, f, wh);`]
    [`void`]
    [
      pre: `a.is_open(b)`.\n
      \n
      Initiates an asynchronous operation to write one or more bytes of data to
      a connected socket `b`. The operation is performed via the `io_service`
      object `a.get_io_service()` and behaves according to [link
      boost_asio.reference.asynchronous_operations asynchronous operation]
      requirements.\n
      \n
      The constant buffer sequence `cb` specifies memory where the data to be
      written is located. The operation shall always write a buffer in the
      sequence completely before proceeding to the next.\n
      \n
      The implementation shall maintain one or more copies of `cb` until such
      time as the write operation no longer requires access to the memory
      specified by the buffers in the sequence. The program must ensure the
      memory is valid until:\n
      \n
      [mdash] the last copy of `cb` is destroyed, or\n
      \n
      [mdash] the handler for the asynchronous operation is invoked,\n
      \n
      whichever comes first.\n
      \n
      If the operation completes successfully, the `WriteHandler` object `wh`
      is invoked with the number of bytes transferred. Otherwise it is invoked
      with `0`.
    ]
  ]
  [
    [``
      const typename Protocol::endpoint& u = e;
      a.send_to(b, cb, u, f, ec);
    ``]
    [`size_t`]
    [
      pre: `a.is_open(b)`.\n
      \n
      Writes one or more bytes of data to an unconnected socket `b`.\n
      \n
      The constant buffer sequence `cb` specifies memory where the data to be
      written is located. The operation shall always write a buffer in the
      sequence completely before proceeding to the next.\n
      \n
      If successful, returns the number of bytes written. Otherwise returns `0`.
    ]
  ]
  [
    [``
      const typename Protocol::endpoint& u = e;
      a.async_send(b, cb, u, f, wh);
    ``]
    [`void`]
    [
      pre: `a.is_open(b)`.\n
      \n
      Initiates an asynchronous operation to write one or more bytes of data to
      an unconnected socket `b`. The operation is performed via the `io_service`
      object `a.get_io_service()` and behaves according to [link
      boost_asio.reference.asynchronous_operations asynchronous operation]
      requirements.\n
      \n
      The constant buffer sequence `cb` specifies memory where the data to be
      written is located. The operation shall always write a buffer in the
      sequence completely before proceeding to the next.\n
      \n
      The implementation shall maintain one or more copies of `cb` until such
      time as the write operation no longer requires access to the memory
      specified by the buffers in the sequence. The program must ensure the
      memory is valid until:\n
      \n
      [mdash] the last copy of `cb` is destroyed, or\n
      \n
      [mdash] the handler for the asynchronous operation is invoked,\n
      \n
      whichever comes first.\n
      \n
      If the operation completes successfully, the `WriteHandler` object `wh`
      is invoked with the number of bytes transferred. Otherwise it is invoked
      with `0`.
    ]
  ]
]

[endsect]