diff options
author | jcej <jcej@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-02-03 00:07:55 +0000 |
---|---|---|
committer | jcej <jcej@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-02-03 00:07:55 +0000 |
commit | 4d06060b347f8d0b035c97e04d1427de98ea79c7 (patch) | |
tree | ecace4a3aa8733b943c47d4c9838fc65b6cc80fa /docs/tutorials | |
parent | 467bba229a50ffd9f97aa2385c3baf98ebe89775 (diff) | |
download | ATCD-4d06060b347f8d0b035c97e04d1427de98ea79c7.tar.gz |
*** empty log message ***
Diffstat (limited to 'docs/tutorials')
-rw-r--r-- | docs/tutorials/001/logger.h | 10 | ||||
-rw-r--r-- | docs/tutorials/001/page04.html | 10 |
2 files changed, 12 insertions, 8 deletions
diff --git a/docs/tutorials/001/logger.h b/docs/tutorials/001/logger.h index 46ed9fa2d02..32546dd5ffb 100644 --- a/docs/tutorials/001/logger.h +++ b/docs/tutorials/001/logger.h @@ -92,10 +92,10 @@ protected: virtual int handle_input (ACE_HANDLE) { /* - Create and initialize a small receive buffer. + Create and initialize a small receive buffer. The extra byte is + there to allow us to have a null-terminated string when it's over. */ - char buf[128]; - memset(buf,0,sizeof(buf)); + char buf[128+1]; /* Invoke the recv() method of the ACE_SOCK_Stream to get some data. It will @@ -120,7 +120,8 @@ protected: passed directly to the underlying OS recv() call. See the man page recv(2) and the header sys/socket.h for the gory details. */ - switch( this->cli_stream_.recv(buf,sizeof buf) ) + ssize_t retval; + switch( retval = this->cli_stream_.recv(buf,sizeof(buf)-1) ) { case -1: ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p bad read\n", "client logger"), -1); @@ -128,6 +129,7 @@ protected: ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) closing log daemon (fd = %d)\n", this->get_handle ()), -1); default: + buf[retval] = '\0'; ACE_DEBUG ((LM_DEBUG, "(%P|%t) from client: %s",buf)); } diff --git a/docs/tutorials/001/page04.html b/docs/tutorials/001/page04.html index 079947a3b3a..18950902db8 100644 --- a/docs/tutorials/001/page04.html +++ b/docs/tutorials/001/page04.html @@ -113,10 +113,10 @@ protected: virtual int handle_input (ACE_HANDLE) { <font color=red>/* - Create and initialize a small receive buffer. + Create and initialize a small receive buffer. The extra byte is + there to allow us to have a null-terminated string when it's over. */</font> - char buf[128]; - memset(buf,0,sizeof(buf)); + char buf[128+1]; <font color=red>/* Invoke the recv() method of the ACE_SOCK_Stream to get some data. It will @@ -141,7 +141,8 @@ protected: passed directly to the underlying OS recv() call. See the man page recv(2) and the header sys/socket.h for the gory details. */</font> - switch( this->cli_stream_.recv(buf,sizeof buf) ) + ssize_t retval; + switch( retval = this->cli_stream_.recv(buf,sizeof(buf)-1) ) { case -1: ACE_ERROR_RETURN ((LM_ERROR, "<font color=green>(%P|%t) %p bad read\n</font>", "<font color=green>client logger</font>"), -1); @@ -149,6 +150,7 @@ protected: ACE_ERROR_RETURN ((LM_ERROR, "<font color=green>(%P|%t) closing log daemon (fd = %d)\n</font>", this->get_handle ()), -1); default: + buf[retval] = '\0'; ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) from client: %s</font>",buf)); } |