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.


  • 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.


  • >= 0
    The number of bytes actually sent on the socket.

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

    'socketDescriptor' is not a valid descriptor.
    Insufficient memory to complete the operation.
    The message was too long.
    The TCP protocol requires usage of recv() not tfRecvFromToInterface().
    The socket is marked as non-blocking and the tfRecvFromToInterface() operation would block.

Table of Contents >> Programmer's Reference