Solved

Socket Buffer length

Posted on 1998-07-08
4
459 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
paragon account problem 9 96
Prevent this page from creating additional dialogs. 3 254
has22 challenge 11 71
sumHeights2  challenge 7 76
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 …
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
This video discusses moving either the default database or any database to a new volume.

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now