tfSendToFromInterface

Jump to: navigation, search

Table of Contents >> Programmer's Reference


#include <trsocket.h>


int tfSendToFromInterface (
int socketDescriptor,
const char * bufferPtr,
int bufferLength,
int flags,
const struct sockaddr * toAddressPtr,
int addressLength,
const struct sockaddr * fromAddressPtr,
const ttUser8BitPtr toPhyAddrPtr,
int toPhyAddrLen,
ttUserInterface interfaceHandle,
unsigned int mhomeIndex
);


Function Description

Same as tfSendToFrom(), but takes 4 extra parameters to let the user specify the link layer destination address, and the interface to send the data through.


Parameters

  • socketDescriptor
    The socket descriptor to use to send the data.
  • bufferPtr
    The buffer to send.
  • bufferLength
    The length of the buffer to send.
  • flags
    MSG_DONTWAIT: Don't wait for room in the socket send queue.
    0: Wait for room in the socket send queue.
  • toAddressPtr
    The address to send the data to.
  • addressLength
    The length of the area pointed to by toAddressPtr or fromAddressPtr.
  • fromAddressPtr
    The address to send the data from.
  • toPhyAddrPtr
    Destination link layer address.
  • toPhyAddrLen
    Destination link layer address length.
  • interfaceHandle
    Interface to send the data through as returned by tfAddInterface().
  • mhomeIndex
    Multihome index on the interface.


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
    The socket descriptor is invalid.
  • TM_EINVAL
    A parameter is invalid.
  • TM_ENOBUFS
    Insufficient memory to complete the operation.
  • TM_EHOSTUNREACH
    No route to destination.
  • TM_ECONNREFUSED
    The socket received an ICMP destination unreachable message from the remote host. This typically means that the receiver is not listening on the remote port.
  • TM_EMSGSIZE
    The message was too long.
  • TM_EPROTOTYPE
    The TCP protocol requires usage of send() not tfSendToFromInterface().
  • TM_EWOULDBLOCK
    The socket is marked as non-blocking and the tfSendToFromInterface() operation would block.


Table of Contents >> Programmer's Reference