Logo Search packages:      
Sourcecode: pwlib version File versions  Download package

BOOL PTCPSocket::Write ( const void *  buf,
PINDEX  len 
) [virtual]

Low level write to the channel. This function will block until the requested number of characters are written or the write timeout is reached. The GetLastWriteCount() function returns the actual number of bytes written.

The GetErrorCode() function should be consulted after Write() returns FALSE to determine what caused the failure.

This override repeatedly writes if there is no error until all of the requested bytes have been written.

Returns:
TRUE if at least len bytes were written to the channel.
Parameters:
buf  Pointer to a block of memory to write.
len  Number of bytes to write.

Reimplemented from PChannel.

Reimplemented in PTelnetSocket.

Definition at line 2723 of file sockets.cxx.

Referenced by PTelnetSocket::SendCommand(), PTelnetSocket::SendSubOption(), PFTPServer::SendToClient(), and PTelnetSocket::Write().

{
  flush();
  PINDEX writeCount = 0;

  while (len > 0) {
    if (!os_sendto(((char *)buf)+writeCount, len, 0, NULL, 0))
      return FALSE;
    writeCount += lastWriteCount;
    len -= lastWriteCount;
  }

  lastWriteCount = writeCount;
  return TRUE;
}


Generated by  Doxygen 1.6.0   Back to index