tfZeroCopySendTo
Table of Contents >> Programmer's Reference
#include <trsocket.h> |
int tfZeroCopySendTo | ( |
int socketDescriptor, | |
ttUserMessage bufferHandle, | |
int bufferLength, | |
int flags, | |
const struct sockaddr TM_FAR * toAddressPtr, | |
int toAddressLength | |
); |
Function Description
This function is used to send a zero copy message. It operates identically to sendto() with the exception that it takes a zero copy buffer handle as a parameter.
Note: | Once tfZeroCopySendTo() is called, the caller does NOT own the buffer and it is freed by the TCP/IP stack, except when if fails with a TM_EWOULDBLOCK error code, in which case the user can either try and send the buffer at a later time, or free the zero copy buffer using tfFreeZeroCopyBuffer(). |
Parameters
- socketDescriptor
- The socket descriptor to send data to.
- bufferHandle
- The zero copy buffer that contains the message.
- bufferLength
- The length of the message to send.
- flags
- See below for possible flags parameters that can be OR'ed together.
- toAddressPtr
- The address to send the packet to.
- toAddressLength
- The length of the destination address.
Flags
Value Meaning MSG_DONTWAIT Don't wait for data, but rather return immediately. MSG_DONTROUTE The SO_DONTROUTE optoin is turned on for the duration of this operation. Only diagnostic or routing progrms use it. MSG_SCATTERED Set this flag when sending a scattered zero copy recv buffer received with tfZeroCopyRecvFrom(). Note that to send a user scattered buffer (not obtained via a call to tfZeroCopyRecvFrom()) then tfSocketScatteredSendTo() can be used.
Returns
- >= 0
- The number of bytes sent.
- TM_SOCKET_ERROR
- Failure.
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_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 socket requires that the message be sent atomically and the message was too long.
- TM_EPROTOTYPE
- The TCP protocol requires usage of tfZeroCopySend() not tfZeroCopySendTo().
- TM_EWOULDBLOCK
- The socket is marked as non-blocking and the operation would block.
- TM_EFAULT
- 'bufferHandle' does not correspond to a zero copy buffer.
- TM_EINVAL
- One of the following:
- bufferLength is less than or equal to 0.
- flags is something besides what is listed above.
- toAddressPtr is null.
- toAddressLength does not equal sizeof(struct sockaddr_in).