Solved

Socket Buffer length

Posted on 1998-07-08
4
463 Views
Last Modified: 2013-11-19
Is there any way to tell the length of the in-Buffer for a socket without disturbing the data in the buffer?
0
Comment
Question by:andy79
  • 2
  • 2
4 Comments
 

Author Comment

by:andy79
ID: 1318874
Edited text of question
0
 
LVL 4

Accepted Solution

by:
piano_boxer earned 50 total points
ID: 1318875
You can get the number of bytes pending in the sockets inputbuffer by calling CAsyncSocket::IOCtl():

"FIONREAD Determine the maximum number of bytes that can be read with one Receive call from this socket. The lpArgument parameter points at a DWORD in which IOCtl stores the result. If this socket is of type SOCK_STREAM, FIONREAD returns the total amount of data which can be read in a single Receive; this is normally the same as the total amount of data queued on the socket. If this socket is of type SOCK_DGRAM, FIONREAD returns the size of the first datagram queued on the socket".

CSomeSocket sock;

DWORD dwBytesAvail = 0;
sock.IOCtl(FIONREAD, &dwBytesAvail);
0
 

Author Comment

by:andy79
ID: 1318876
I mean, the number of bytes in the buffer that are ready to be read.
0
 
LVL 4

Expert Comment

by:piano_boxer
ID: 1318877
Thats it!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
WinWaitActive parameters 12 31
maven archtype selection in eclipse 1 57
zeroMAx challenge 20 111
Capture logon name 13 86
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question