tfRead

Jump to: navigation, search

Table of Contents >> Programmer's Reference


#include <trsocket.h>


int tfRead (
int socketDescriptor,
char * bufferPtr,
int bufferLength
);


Function Description

tfRead() is used to receive messages from another socket. It is not called read to avoid confusion with an embedded kernel file system call. It operates identically to recv(), except that it does not have any flag parameter, and hence does not support out-of-band data, or overwriting the blocking state of the socket for the duration of the call.


Parameters

  • socketDescriptor
    The socket descriptor to receive data from.
  • bufferPtr
    The buffer to put the received data into.
  • bufferLength
    The length of the buffer area that bufferPtr points to.


Return Values

  • > 0
    The number of bytes actually received from the socket.
  • TM_ENOERROR
    EOF.
  • TM_SOCKET_ERROR
    Failure.


Note Note: TM_SOCKET_ERROR means that this socket call has failed and the errorCode has been set on the socket itself.

To retrieve the socket error the user must call tfGetSocketError(socketDescriptor).


Possible socket errors

  • TM_EBADF
    The socket descriptor is invalid.
  • TM_ENOBUFS
    Insufficient memory to complete the operation.
  • TM_EMSGSIZE
    The socket requires that the message be received atomically and bufferLength was too small.
  • TM_EWOULDBLOCK
    The socket is marked as non-blocking and no data is available to be read.
  • TM_ESHUTDOWN
    The remote socket has closed the connection and there is no more data to be read (TCP socket only).
  • TM_ENOTCONN
    The socket is not connected.
  • TM_EINVAL
    One of the parameters is invalid.
  • TM_ETIMEDOUT
    The TCP connection has timed out.


Table of Contents >> Programmer's Reference