• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 472
  • Last Modified:

Socket Buffer length

Is there any way to tell the length of the in-Buffer for a socket without disturbing the data in the buffer?
0
andy79
Asked:
andy79
  • 2
  • 2
1 Solution
 
andy79Author Commented:
Edited text of question
0
 
piano_boxerCommented:
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
 
andy79Author Commented:
I mean, the number of bytes in the buffer that are ready to be read.
0
 
piano_boxerCommented:
Thats it!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now