Skip to content

Instantly share code, notes, and snippets.

@kegilbert
Last active November 20, 2018 00:10
Show Gist options
  • Save kegilbert/b7e1404ead82e417c9e640f84c73a576 to your computer and use it in GitHub Desktop.
Save kegilbert/b7e1404ead82e417c9e640f84c73a576 to your computer and use it in GitHub Desktop.
/**
 * Get the last allocated socket object.
 * User would only need to allocate one socket object rather than the number
 * of all socket objects currently in use/previously closed.
 */
int mbed_stats_socket_get_last(mbed_stats_socket_t * last_socket);

/**
 * Get all TCP socket objects
 */
int mbed_stats_socket_get_tcp(mbed_stats_socket_t * tcp_sockets, int count);


/**
 * Get all UDP socket objects
 */
 int mbed_stats_socket_get_udp(mbed_stats_socket_t * udp_sockets, int count);


/**
 * Get socket object by id (socket address). Can be used by Socket classes to
 * return information related to that particlar object. See below
 */
 const mbed_stats_socket_t* SocketStats::socket_get_by_id(Socket * socket);

/**
 *  Get number of bytes sent by TCPSocket object
 *
 * @code
 *  TCPSocket sock(...);
 *  // Do Stuff 
 *  printf("Socket sent: %d bytes\r\n", sock.get_bytes_sent());
 * @endcode
 */
int TCPSocket::get_bytes_sent(void) {
    return _socket_stats.stats_socket_get_by_id(this)->sent_bytes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment