Jump to: navigation, search

Table of Contents >> Programmer's Reference

#include <trsocket.h>

int qossendto (
int socketDescriptor,
char * bufferPtr,
int bufferLength,
int tos,
int flags,
const struct sockaddr * toAddressPtr

Function Description

qossendto() is identical to sendto() with the exception of the tos parameter. This parameters allows the caller to specify the Quality Of Service for the data being sent on a per-call basis, rather than with the per-socket basis. It is important to note that, unlike the per-socket method where all of the data is sent with the QOS value that is on the socket when the data is sent, this allows the caller to place several pieces of data in the same send queue with differing QOS values. qossendto() is used to transmit a message to another transport end-point. qossendto() may be used any time the socket is in the unconnected state, and never for TCP sockets. socketDescriptor is a socket created with socket(). The address of the target is given by to with toAddressLength specifying its size. If the message is too long to pass atomically through the underlying protocol, then TM_SOCKET_ERROR is returned with the socket error being set to TM_EMSGSIZE and the message is not transmitted. A return value of TM_SOCKET_ERROR indicates locally detected errors only. A positive return value does not implicitly mean the message was delivered, but rather that it was sent. If the socket does not have enough buffer space available to hold the message being sent, and is in blocking mode, qossendto() blocks. If it is in non-blocking mode or the MSG_DONTWAIT flag has been set in the flags parameter, TM_SOCKET_ERROR is returned with the socket error being set to TM_EWOULDBLOCK. The select() call may be used to determine when it is possible to send more data.


  • socketDescriptor
    The socket descriptor to use to send the data.
  • bufferPtr
    A pointer to the buffer to send.
  • bufferLength
    The length of the buffer to send.
  • flags
    See below for possible flags parameters that can be OR'ed together.
  • toAddressPtr
    The address to send the data to.
  • toAddressLength
    The length of address specified by toAddressPtr.


Value Meaning
MSG_DONTWAIT Don't wait for the data send to complete, but rather return immediately.
MSG_DONTROUTE The SO_DONTROUTE option is turned on for the duration of the operation. Only diagnostic or routing programs use it.

Return Values

  • >= 0
    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

    The socket descriptor is invalid.
    One of the following:
  • bufferPtr is 0.
  • bufferLength is less than or equal to 0.
  • flags is something besides what is listed above.
    Insufficient memory to complete the operation.
    No route to destination.
    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.
    The destionation host is down.
    The socket requires that the message be sent atomically and the message was too long.
    The TCP protocol requires usage of qossend(), not qossendto().
    The socket is marked as non-blocking and the qossend() operation would block.

Table of Contents >> Programmer's Reference