Solved

Socket Buffer length

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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 Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
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.

920 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

11 Experts available now in Live!

Get 1:1 Help Now