/* Get the length of the free space of the specific socket buffer. */
UINT32 SockGetFreeSpace(IN SOCKET *Sock, IN UINT32 Which)
/* Get the length of the free space of the specific socket buffer. */
UINT32 SockGetFreeSpace(IN SOCKET *Sock, IN UINT32 Which)
{
  UINT32       BufferCC;
  SOCK_BUFFER  *SockBuffer;
  ASSERT (Sock != NULL && ((SOCK_SND_BUF == Which) || (SOCK_RCV_BUF == Which)));
  if (SOCK_SND_BUF == Which) {
    SockBuffer = &(Sock->SndBuffer);
  } else {
    SockBuffer = &(Sock->RcvBuffer);
  }
  BufferCC = (SockBuffer->DataQueue)->BufSize;
  if (BufferCC >= SockBuffer->HighWater) {
    return 0;
  }
  return SockBuffer->HighWater - BufferCC;
}