how to clear socket buffer

can9999
can9999 used Ask the Experts™
on
I had set socket buffer like this..

buf_size =16*1024;

err = setsockopt( m_hSock, SOL_SOCKET, SO_SNDBUF, (char *)&buf_size, sizeof(buf_size));

Everything ok while sending data to client...

My question is
I want to clear data in the buffer and send data immediately sometimes.

How can I do that ?

thanks.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
hmm u could write a routine to set all values in the array to 0 maybe?

while (i != arraysize):
{
    buf_size[i] = 0;
    i++;
}

that can be used to initialise the array to zero.

hmm i wonder does  fflush(buf_size); work,  try it and see, i have no programmig tools on this heap of shite lol
:)

Author

Commented:
^^ I want to clear socket buffer not memory.

Have a look at http://www.developerweb.net/sock-faq/detail.php?id=17.  This document says that basically you can't force your data to be flushed, it's down to the TCP layer of the protocol stack to decide when to send data.  It does suggest you can set TCP_NODELAY flag which may achieve what you want it to.

Have a look at http://www.developerweb.net/sock-faq/detail.php?id=22 to see how to use it.

Hope this helps

Author

Commented:
you gave me what I exactly wanted. ^^

thanks .

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial