[ace-users] recv()
Douglas C. Schmidt
schmidt at dre.vanderbilt.edu
Tue Jul 10 14:31:23 CDT 2007
Hi Leon,
>On 7/9/07, Albert Sanchez <ouferrat at gmail.com> wrote:
>> How can I know after recv() how many bytes were actually received and if
>> there's still something to receive??
>
>If I'm not mistaken, you provide recv () with a pointer to the buffer
>and the buffer size you want the fresh data to be stored in, and it
>returns the amount of bytes.
That's correct. Here's the documentation from ACE_ROOT/ace/SOCK_IO.h:
/**
* @class ACE_SOCK_IO
*
* @brief Defines the methods for the ACE socket wrapper I/O routines
* (e.g., send/recv).
*
* If @a timeout == 0, then the call behaves as a normal
* send/recv call, i.e., for blocking sockets, the call will
* block until action is possible; for non-blocking sockets,
* -1 will be returned with errno == EWOULDBLOCK if no action is
* immediately possible.
* If @a timeout != 0, the call will wait until the relative time
* specified in *@a timeout elapses.
* Errors are reported by -1 and 0 return values. If the
* operation times out, -1 is returned with <errno == ETIME>.
* If it succeeds the number of bytes transferred is returned.
* Methods with the extra <flags> argument will always result in
* <send> getting called. Methods without the extra <flags>
* argument will result in <send> getting called on Win32
* platforms, and <write> getting called on non-Win32 platforms.
*/
> The best way to see whether a socket still has data available is to
> use a select ()-based event handling system, such as the Reactor. If
> an event arrives on the socket, and you have read 0 or -1 bytes, you
> know that the connection has been/should be closed.
Right! Please see Chapter 3 and 4 of C++NPv2
<www.cs.wustl.edu/~schmidt/ACE/book2/> for more details and examples.
Thanks,
Doug
--
Dr. Douglas C. Schmidt Professor and Associate Chair
Electrical Engineering and Computer Science TEL: (615) 343-8197
Vanderbilt University WEB: www.dre.vanderbilt.edu/~schmidt
Nashville, TN 37203 NET: d.schmidt at vanderbilt.edu
More information about the Ace-users
mailing list