32
32
*/
33
33
class InternetSocket : public Socket {
34
34
public:
35
- /* * Destroy a socket
35
+ /* * Destroy the socket.
36
36
*
37
- * Closes socket if the socket is still open
37
+ * @note Closes socket if it's still open.
38
38
*/
39
39
virtual ~InternetSocket () {}
40
40
41
- /* * Opens a socket
41
+ /* * Open a network socket on the network stack of the given
42
+ * network interface.
42
43
*
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.
46
45
*
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).
49
48
*/
50
49
nsapi_error_t open (NetworkStack *stack);
51
50
51
+ #if !defined(DOXYGEN_ONLY)
52
52
template <typename S>
53
53
nsapi_error_t open (S *stack)
54
54
{
55
55
return open (nsapi_create_stack (stack));
56
56
}
57
+ #endif // !defined(DOXYGEN_ONLY)
57
58
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
61
60
* with the socket. Called from destructor if socket is not closed.
62
61
*
63
- * @return 0 on success, negative error code on failure
62
+ * @return 0 on success, negative error code on failure (@see nsapi_types.h).
64
63
*/
65
64
virtual nsapi_error_t close ();
66
65
67
- /* * Subscribes to an IP multicast group
66
+ /* * Subscribe to an IP multicast group.
68
67
*
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).
71
70
*/
72
71
int join_multicast_group (const SocketAddress &address);
73
72
74
- /* * Leave an IP multicast group
73
+ /* * Leave an IP multicast group.
75
74
*
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).
78
77
*/
79
78
int leave_multicast_group (const SocketAddress &address);
80
79
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.
86
81
*
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) .
89
84
*/
90
85
nsapi_error_t bind (uint16_t port);
91
86
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.
96
89
*
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) .
100
93
*/
101
94
nsapi_error_t bind (const char *address, uint16_t port);
102
95
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
106
97
* data. If the IP address is zeroed, only the port is bound.
107
98
*
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) .
110
101
*/
111
102
virtual nsapi_error_t bind (const SocketAddress &address);
112
103
113
- /* * Set blocking or non-blocking mode of the socket
104
+ /* * Set blocking or non-blocking mode of the socket.
114
105
*
115
106
* Initially all sockets are in blocking mode. In non-blocking mode
116
107
* blocking operations such as send/recv/accept return
117
108
* NSAPI_ERROR_WOULD_BLOCK if they can not continue.
118
109
*
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).
121
112
*
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.
123
114
*/
124
115
virtual void set_blocking (bool blocking);
125
116
126
- /* * Set timeout on blocking socket operations
117
+ /* * Set timeout on blocking socket operations.
127
118
*
128
119
* Initially all sockets have unbounded timeouts. NSAPI_ERROR_WOULD_BLOCK
129
120
* is returned if a blocking operation takes longer than the specified
130
121
* timeout. A timeout of 0 removes the timeout from the socket. A negative
131
122
* value give the socket an unbounded timeout.
132
123
*
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).
135
126
*
136
- * @param timeout Timeout in milliseconds
127
+ * @param timeout Timeout in milliseconds.
137
128
*/
138
129
virtual void set_timeout (int timeout);
139
130
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.
145
133
*
146
134
* For unsupported options, NSAPI_ERROR_UNSUPPORTED is returned
147
135
* and the socket is unmodified.
148
136
*
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).
154
142
*/
155
143
virtual nsapi_error_t setsockopt (int level, int optname, const void *optval, unsigned optlen);
156
144
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.
162
148
*
163
149
* For unsupported options, NSAPI_ERROR_UNSUPPORTED is returned
164
150
* and the socket is unmodified.
165
151
*
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).
171
157
*/
172
158
virtual nsapi_error_t getsockopt (int level, int optname, void *optval, unsigned *optlen);
173
159
174
- /* * Register a callback on state change of the socket
160
+ /* * Register a callback on state change of the socket.
175
161
*
176
162
* 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.
179
165
*
180
166
* The callback may be called in an interrupt context and should not
181
167
* perform expensive operations such as recv/send calls.
182
168
*
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
185
171
* 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.
187
173
*
188
- * @param func Function to call on state change
174
+ * @param func Function to call on state change.
189
175
*/
190
176
virtual void sigio (mbed::Callback<void ()> func);
191
177
192
- /* * Register a callback on state change of the socket
178
+ /* * Register a callback on state change of the socket.
193
179
*
194
180
* @see Socket::sigio
195
181
* @deprecated
@@ -201,7 +187,7 @@ class InternetSocket : public Socket {
201
187
" mbed OS and has been known to cause confusion. Replaced by Socket::sigio." )
202
188
void attach (mbed::Callback<void ()> func);
203
189
204
- /* * Register a callback on state change of the socket
190
+ /* * Register a callback on state change of the socket.
205
191
*
206
192
* @see Socket::sigio
207
193
* @deprecated
@@ -217,6 +203,8 @@ class InternetSocket : public Socket {
217
203
attach (mbed::callback (obj, method));
218
204
}
219
205
206
+ #if !defined(DOXYGEN_ONLY)
207
+
220
208
protected:
221
209
InternetSocket ();
222
210
virtual nsapi_protocol_t get_proto () = 0;
@@ -240,6 +228,8 @@ class InternetSocket : public Socket {
240
228
static const int READ_FLAG = 0x1u ;
241
229
static const int WRITE_FLAG = 0x2u ;
242
230
static const int FINISHED_FLAG = 0x3u ;
231
+
232
+ #endif // !defined(DOXYGEN_ONLY)
243
233
};
244
234
245
235
#endif // INTERNETSOCKET_H
0 commit comments