Data pending... please read
I am trying to avoid multithreading in my program (no, I can''t use any WINAPI sync stuff) and it would be very convenient to be able to find out how many bytes are pending, or just if there are any pending or not. Does anyone know how to do this with Winsock?
Really I just need to know IF there are any pending, but how many is good aswell.
Thanks, ~SPH
AIM ME: aGaBoOgAmOnGeR
DWORD YourSocketClass::BytesPending() const
{
DWORD dwPending = 0;
if( m_hSocket != INVALID_SOCKET )
ioctlsocket( m_hSocket, FIONREAD, &dwPending );//this is the interesting line![](smile.gif)
return( dwPending );
};
{
DWORD dwPending = 0;
if( m_hSocket != INVALID_SOCKET )
ioctlsocket( m_hSocket, FIONREAD, &dwPending );//this is the interesting line
![](smile.gif)
return( dwPending );
};
Darkhaven Beta-test stage coming soon.
Thanks, but I eventually found that I could use the select function to do it, is there an advantage to using ioctlsocket ?
~SPH
AIM ME: aGaBoOgAmOnGeR
quote:
Thanks, but I eventually found that I could use the select function to do it, is there an advantage to using ioctlsocket ?
Yes, the ioctl can be used for a single specific socket with less overhead compared to using select() for a single socket. When using select, keep in mind that it is implemented differently on Windows than on other systems. This could lead to performance problems in porting to different platforms.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement