Skip to content

Commit fd0612b

Browse files
update internetsocket docs
1 parent ba23fef commit fd0612b

File tree

2 files changed

+66
-76
lines changed

2 files changed

+66
-76
lines changed

features/netsocket/InternetSocket.h

Lines changed: 64 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -32,164 +32,150 @@
3232
*/
3333
class InternetSocket : public Socket {
3434
public:
35-
/** Destroy a socket
35+
/** Destroy the socket.
3636
*
37-
* Closes socket if the socket is still open
37+
* @note Closes socket if it's still open.
3838
*/
3939
virtual ~InternetSocket() {}
4040

41-
/** Opens a socket
41+
/** Open a network socket on the network stack of the given
42+
* network interface.
4243
*
43-
* Creates a network socket on the network stack of the given
44-
* network interface. Not needed if stack is passed to the
45-
* socket's constructor.
44+
* @note Not needed if stack is passed to the socket's constructor.
4645
*
47-
* @param stack Network stack as target for socket
48-
* @return 0 on success, negative error code on failure
46+
* @param stack Network stack as target for socket.
47+
* @return 0 on success, negative error code on failure (@see nsapi_types.h).
4948
*/
5049
nsapi_error_t open(NetworkStack *stack);
5150

51+
#if !defined(DOXYGEN_ONLY)
5252
template <typename S>
5353
nsapi_error_t open(S *stack)
5454
{
5555
return open(nsapi_create_stack(stack));
5656
}
57+
#endif //!defined(DOXYGEN_ONLY)
5758

58-
/** Close the socket
59-
*
60-
* Closes any open connection and deallocates any memory associated
59+
/** Close any open connection and deallocate any memory associated
6160
* with the socket. Called from destructor if socket is not closed.
6261
*
63-
* @return 0 on success, negative error code on failure
62+
* @return 0 on success, negative error code on failure (@see nsapi_types.h).
6463
*/
6564
virtual nsapi_error_t close();
6665

67-
/** Subscribes to an IP multicast group
66+
/** Subscribe to an IP multicast group.
6867
*
69-
* @param address Multicast group IP address
70-
* @return Negative error code on failure
68+
* @param address Multicast group IP address.
69+
* @return 0 on success, negative error code on failure (@see nsapi_types.h).
7170
*/
7271
int join_multicast_group(const SocketAddress &address);
7372

74-
/** Leave an IP multicast group
73+
/** Leave an IP multicast group.
7574
*
76-
* @param address Multicast group IP address
77-
* @return Negative error code on failure
75+
* @param address Multicast group IP address.
76+
* @return 0 on success, negative error code on failure (@see nsapi_types.h).
7877
*/
7978
int leave_multicast_group(const SocketAddress &address);
8079

81-
82-
/** Bind a specific address to a socket
83-
*
84-
* Binding a socket specifies the address and port on which to receive
85-
* data.
80+
/** Bind the socket to a port on which to receive data.
8681
*
87-
* @param port Local port to bind
88-
* @return 0 on success, negative error code on failure.
82+
* @param port Local port to bind.
83+
* @return 0 on success, negative error code on failure (@see nsapi_types.h).
8984
*/
9085
nsapi_error_t bind(uint16_t port);
9186

92-
/** Bind a specific address to a socket
93-
*
94-
* Binding a socket specifies the address and port on which to receive
95-
* data. If the IP address is zeroed, only the port is bound.
87+
/** Bind the socket to a specific address and port on which to receive
88+
* data. If the IP address is zeroed only the port is bound.
9689
*
97-
* @param address Null-terminated local address to bind
98-
* @param port Local port to bind
99-
* @return 0 on success, negative error code on failure.
90+
* @param address Null-terminated local address to bind.
91+
* @param port Local port to bind.
92+
* @return 0 on success, negative error code on failure (@see nsapi_types.h).
10093
*/
10194
nsapi_error_t bind(const char *address, uint16_t port);
10295

103-
/** Bind a specific address to a socket
104-
*
105-
* Binding a socket specifies the address and port on which to receive
96+
/** Bind the socket to a specific address and port on which to receive
10697
* data. If the IP address is zeroed, only the port is bound.
10798
*
108-
* @param address Local address to bind
109-
* @return 0 on success, negative error code on failure.
99+
* @param address Local SocketAddress to bind which includes the address and port.
100+
* @return 0 on success, negative error code on failure (@see nsapi_types.h).
110101
*/
111102
virtual nsapi_error_t bind(const SocketAddress &address);
112103

113-
/** Set blocking or non-blocking mode of the socket
104+
/** Set blocking or non-blocking mode of the socket.
114105
*
115106
* Initially all sockets are in blocking mode. In non-blocking mode
116107
* blocking operations such as send/recv/accept return
117108
* NSAPI_ERROR_WOULD_BLOCK if they can not continue.
118109
*
119-
* set_blocking(false) is equivalent to set_timeout(-1)
120-
* set_blocking(true) is equivalent to set_timeout(0)
110+
* @note set_blocking(false) is equivalent to set_timeout(-1) and
111+
* set_blocking(true) is equivalent to set_timeout(0).
121112
*
122-
* @param blocking true for blocking mode, false for non-blocking mode.
113+
* @param blocking Use true for blocking mode, false for non-blocking mode.
123114
*/
124115
virtual void set_blocking(bool blocking);
125116

126-
/** Set timeout on blocking socket operations
117+
/** Set timeout on blocking socket operations.
127118
*
128119
* Initially all sockets have unbounded timeouts. NSAPI_ERROR_WOULD_BLOCK
129120
* is returned if a blocking operation takes longer than the specified
130121
* timeout. A timeout of 0 removes the timeout from the socket. A negative
131122
* value give the socket an unbounded timeout.
132123
*
133-
* set_timeout(0) is equivalent to set_blocking(false)
134-
* set_timeout(-1) is equivalent to set_blocking(true)
124+
* @note set_timeout(0) is equivalent to set_blocking(false) and
125+
* set_timeout(-1) is equivalent to set_blocking(true).
135126
*
136-
* @param timeout Timeout in milliseconds
127+
* @param timeout Timeout in milliseconds.
137128
*/
138129
virtual void set_timeout(int timeout);
139130

140-
/* Set socket options
141-
*
142-
* setsockopt allows an application to pass stack-specific options
143-
* to the underlying stack using stack-specific level and option names,
144-
* or to request generic options using levels from nsapi_socket_level_t.
131+
/** Pass stack-specific options to the underlying stack using stack-specific
132+
* level and option names, or request generic options using levels from nsapi_socket_level_t.
145133
*
146134
* For unsupported options, NSAPI_ERROR_UNSUPPORTED is returned
147135
* and the socket is unmodified.
148136
*
149-
* @param level Stack-specific protocol level or nsapi_socket_level_t
150-
* @param optname Level-specific option name
151-
* @param optval Option value
152-
* @param optlen Length of the option value
153-
* @return 0 on success, negative error code on failure
137+
* @param level Stack-specific protocol level or nsapi_socket_level_t.
138+
* @param optname Level-specific option name.
139+
* @param optval Option value.
140+
* @param optlen Length of the option value.
141+
* @return 0 on success, negative error code on failure (@see nsapi_types.h).
154142
*/
155143
virtual nsapi_error_t setsockopt(int level, int optname, const void *optval, unsigned optlen);
156144

157-
/* Get socket options
158-
*
159-
* getsockopt allows an application to retrieve stack-specific options
160-
* from the underlying stack using stack-specific level and option names,
161-
* or to request generic options using levels from nsapi_socket_level_t.
145+
/** Retrieve stack-specific options from the underlying stack using
146+
* stack-specific level and option names, or request generic options
147+
* using levels from nsapi_socket_level_t.
162148
*
163149
* For unsupported options, NSAPI_ERROR_UNSUPPORTED is returned
164150
* and the socket is unmodified.
165151
*
166-
* @param level Stack-specific protocol level or nsapi_socket_level_t
167-
* @param optname Level-specific option name
168-
* @param optval Destination for option value
169-
* @param optlen Length of the option value
170-
* @return 0 on success, negative error code on failure
152+
* @param level Stack-specific protocol level or nsapi_socket_level_t.
153+
* @param optname Level-specific option name.
154+
* @param optval Destination for option value.
155+
* @param optlen Length of the option value.
156+
* @return 0 on success, negative error code on failure (@see nsapi_types.h).
171157
*/
172158
virtual nsapi_error_t getsockopt(int level, int optname, void *optval, unsigned *optlen);
173159

174-
/** Register a callback on state change of the socket
160+
/** Register a callback on state change of the socket.
175161
*
176162
* The specified callback will be called on state changes such as when
177-
* the socket can recv/send/accept successfully and on when an error
178-
* occurs. The callback may also be called spuriously without reason.
163+
* the socket can recv/send/accept successfully and when an error
164+
* occurs. The callback may also be called spuriously without a reason.
179165
*
180166
* The callback may be called in an interrupt context and should not
181167
* perform expensive operations such as recv/send calls.
182168
*
183-
* Note! This is not intended as a replacement for a poll or attach-like
184-
* asynchronous api, but rather as a building block for constructing
169+
* @note This is not intended as a replacement for a poll or attach-like
170+
* asynchronous API, but rather as a building block for constructing
185171
* such functionality. The exact timing of when the registered function
186-
* is called is not guaranteed and susceptible to change.
172+
* is called is not guaranteed and is susceptible to change.
187173
*
188-
* @param func Function to call on state change
174+
* @param func Function to call on state change.
189175
*/
190176
virtual void sigio(mbed::Callback<void()> func);
191177

192-
/** Register a callback on state change of the socket
178+
/** Register a callback on state change of the socket.
193179
*
194180
* @see Socket::sigio
195181
* @deprecated
@@ -201,7 +187,7 @@ class InternetSocket : public Socket {
201187
"mbed OS and has been known to cause confusion. Replaced by Socket::sigio.")
202188
void attach(mbed::Callback<void()> func);
203189

204-
/** Register a callback on state change of the socket
190+
/** Register a callback on state change of the socket.
205191
*
206192
* @see Socket::sigio
207193
* @deprecated
@@ -217,6 +203,8 @@ class InternetSocket : public Socket {
217203
attach(mbed::callback(obj, method));
218204
}
219205

206+
#if !defined(DOXYGEN_ONLY)
207+
220208
protected:
221209
InternetSocket();
222210
virtual nsapi_protocol_t get_proto() = 0;
@@ -240,6 +228,8 @@ class InternetSocket : public Socket {
240228
static const int READ_FLAG = 0x1u;
241229
static const int WRITE_FLAG = 0x2u;
242230
static const int FINISHED_FLAG = 0x3u;
231+
232+
#endif //!defined(DOXYGEN_ONLY)
243233
};
244234

245235
#endif // INTERNETSOCKET_H

features/netsocket/Socket.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ class Socket {
194194
*/
195195
virtual void sigio(mbed::Callback<void()> func) = 0;
196196

197-
/* Set socket options.
197+
/** Set socket options.
198198
*
199199
* setsockopt() allows an application to pass stack-specific options
200200
* to the underlying stack using stack-specific level and option names,
@@ -211,7 +211,7 @@ class Socket {
211211
*/
212212
virtual nsapi_error_t setsockopt(int level, int optname, const void *optval, unsigned optlen) = 0;
213213

214-
/* Get socket options.
214+
/** Get socket options.
215215
*
216216
* getsockopt() allows an application to retrieve stack-specific options
217217
* from the underlying stack using stack-specific level and option names,

0 commit comments

Comments
 (0)