Skip to content

Commit 4f8361e

Browse files
Some minor doc improvements (#453)
* Some minor doc improvements * Reword
1 parent da2819e commit 4f8361e

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

connectivity/netsocket/include/netsocket/Socket.h

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ class Socket {
5050
* Closes any open connection and deallocates any memory associated
5151
* with the socket. Called from destructor if socket is not closed.
5252
*
53+
* If this socket was allocated by an accept() call, then calling this will also delete
54+
* the socket object itself.
55+
*
5356
* @return NSAPI_ERROR_OK on success.
5457
* Negative subclass-dependent error code on failure.
5558
*/
@@ -307,20 +310,22 @@ class Socket {
307310
*/
308311
virtual nsapi_error_t getsockopt(int level, int optname, void *optval, unsigned *optlen) = 0;
309312

310-
/** Accepts a connection on a socket.
313+
/**
314+
* @brief Waits for a client to try to connect to this socket, then returns a socket for the new connection.
315+
*
316+
* On error, returns nullptr and sets the error code parameter (if provided).
311317
*
312-
* The server socket must be bound and set to listen for connections.
313-
* On a new connection, returns connected network socket to call close()
314-
* that deallocates the resources. Referencing a returned pointer after a close()
315-
* call is not allowed and leads to undefined behavior.
318+
* Note that if a socket is returned, you must eventually call close() on it to release its resources.
319+
* Calling close() will also delete the socket object, no separate \c delete is required.
320+
* Referencing the returned socket after a close() call is not allowed and leads to undefined behavior.
316321
*
317-
* By default, accept blocks until incoming connection occurs. If socket is set to
318-
* non-blocking or times out, error is set to NSAPI_ERROR_WOULD_BLOCK.
322+
* By default, this function blocks until an incoming connection occurs. If socket is set to
323+
* non-blocking or times out, an \c NSAPI_ERROR_WOULD_BLOCK error is returned.
319324
*
320-
* @param error Pointer to storage of the error value or NULL.
321-
* @return Pointer to a socket.
325+
* @param error If you wish to check the error code, pass an error code pointer here.
326+
* @return Pointer to a socket, or nullptr on error
322327
*/
323-
virtual Socket *accept(nsapi_error_t *error = NULL) = 0;
328+
virtual Socket *accept(nsapi_error_t *error = nullptr) = 0;
324329

325330
/** Listen for incoming connections.
326331
*

rtos/include/rtos/Thread.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,13 @@ class Thread : private mbed::NonCopyable<Thread> {
241241
*/
242242
const char *get_name() const;
243243

244-
/** Get thread id
245-
@return thread ID for reference by other functions.
246-
247-
@note You may call this function from ISR context.
244+
/**
245+
* @brief Get thread ID
246+
* @return Unique ID number of this thread. No other running thread will have this ID number.
247+
*
248+
* If the thread is not running, or has not started yet, 0 will be returned.
249+
*
250+
* @note You may call this function from ISR context.
248251
*/
249252
osThreadId_t get_id() const;
250253

0 commit comments

Comments
 (0)