From 91ed9541e2598d8edfe1a5eaa5908760ea1edb4c Mon Sep 17 00:00:00 2001 From: Daniele Basile Date: Fri, 20 Jan 2012 16:55:47 +0100 Subject: [PATCH] Add comments. --- bertos/net/tcp_socket.c | 9 +++++++++ bertos/net/tcp_socket.h | 16 ++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/bertos/net/tcp_socket.c b/bertos/net/tcp_socket.c index 030f55f3..98e743ad 100644 --- a/bertos/net/tcp_socket.c +++ b/bertos/net/tcp_socket.c @@ -130,6 +130,15 @@ static KFile *tcpsocket_reopen(KFile *fd) return NULL; } +/* + * Read data from socket. + * + * The read return the bytes that had been received if they are less than we request too. + * Otherwise if the byte that we want read are less that the received bytes, we return only + * the requested bytes. To get the remaning bytes we need to make an others read, until the + * buffer is empty. + * When there are not any more bytes, a new read takes data from remote socket. + */ static size_t tcpsocket_read(KFile *fd, void *buf, size_t len) { TcpSocket *socket = TCPSOCKET_CAST(fd); diff --git a/bertos/net/tcp_socket.h b/bertos/net/tcp_socket.h index 0791c187..74ca1074 100644 --- a/bertos/net/tcp_socket.h +++ b/bertos/net/tcp_socket.h @@ -48,16 +48,16 @@ typedef struct TcpSocket { - KFile fd; - struct netconn *sock; - struct netbuf *rx_buf_conn; - size_t remaning_data_len; + KFile fd; ///< KFile context. + struct netconn *sock; ///< Current sockect connection pointer. + struct netbuf *rx_buf_conn; ///< Current received buffer from socket. + size_t remaning_data_len; ///< Number of bytes to read from the received buffer. - struct ip_addr *local_addr; - struct ip_addr *remote_addr; - uint16_t port; + struct ip_addr *local_addr; ///< Device Ip. + struct ip_addr *remote_addr; ///< Ip address which we want to connect. + uint16_t port; ///< Number port to connect. - int error; + int error; ///< Error status. } TcpSocket; #define KFT_TCPSOCKET MAKE_ID('T', 'S', 'C', 'K') -- 2.25.1