tfRecvFromToInterface

Jump to: navigation, search

Table of Contents >> Programmer's Reference


#include <trsocket.h>


int tfRecvFromToInterface (
int socketDescriptor,
char * bufferPtr,
int bufferLength,
int flags,
struct sockaddr * fromAddressPtr,
int * addressLengthPtr,
struct sockaddr * toAddressPtr,
ttUser8BitPtr fromPhyAddrPtr,
ttUserIntPtr fromPhyAddrLenPtr,
ttUserInterfacePtr interfaceHandlePtr
);


Function Description

Take some data from the receive queue and give it to the user. Same as tfRecvFromTo(), but takes 3 extra parameters to let the user get the link layer source address of the packet and the interface the packet arrived on.


Parameters

  • socketDescriptor
    The socket descriptor to use to receive the data.
  • bufferPtr
    The buffer to store the received data.
  • bufferLength
    The length of the buffer to store the received data.
  • flags
    MSG_DONTWAIT: Don't wait for the data
    0: Wait for data to arrive.
  • fromAddressPtr
    Where to store the address the data came from.
  • addressLengthPtr
    Length of the area point to by fromAddressPtr or toAddressPtr.
  • toAddressPtr
    A pointer to the location to store the address the data was sent to.
  • fromPhyAddrPtr
    A pointer to the location to store the link layer address that the packet came from.
  • fromPhyAddrLenPtr
    A pointer to the length of the area pointed to by fromPhyAddrPtr. The length is updated to the length of the address copied.
  • interfaceHandlePtr
    A pointer to the interface handle (as returned by tfAddInterface()) that the packet arrived on.


Returns

  • >= 0
    The number of bytes actually sent on the socket.
  • 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
    'socketDescriptor' is not a valid descriptor.
  • TM_ENOBUFS
    Insufficient memory to complete the operation.
  • TM_EMSGSIZE
    The message was too long.
  • TM_EPROTOTYPE
    The TCP protocol requires usage of recv() not tfRecvFromToInterface().
  • TM_EWOULDBLOCK
    The socket is marked as non-blocking and the tfRecvFromToInterface() operation would block.


Table of Contents >> Programmer's Reference