Esempio n. 1
0
// Returns <0 on failure, otherwise the number of bytes left in the buffer
ssize_t BufIo::FlushOut(SOCKET sk)
{
  ssize_t r;
  if( !m_len ) return 0;  // no data to send

  r = _SEND(sk, m_buf, m_len);
  if( r < 0 ){
    m_valid = 0;
    return r;
  }else if( r > 0 ){
    m_len -= r;
    if( m_len ) memmove(m_buf, m_buf + r, m_len);
  }
  return (ssize_t)m_len;
}
Esempio n. 2
0
ssize_t BufIo::FlushOut(SOCKET sk)
{
	ssize_t r;
	if (!p)
		return 0; // no data to be send

	r = _SEND(sk, b, p);
	if (r < 0)
		return r;
	else if (r > 0) {
		p -= r;
		if (p)
			memmove(b, b + r, p);
	}
	return(ssize_t) p;
}