#include "spx_app.h"int t_snd ( int spxFd, char *buf, unsigned int nbytes, int flags )
spxFd
buf
nbytes
flags
Following the TLI specification, any t_snd issued in the T_IDLE state is dropped by the SPXII driver. From the SPX/SPXII user's point of view, this indication is noticed only if that user issues some call other than t_snd.
The SPX/SPXII user should check the return code in the disconnect indication to make sure it is TLI_SPX_CONNECTION_TERMINATED.
The following errors can occur during the send request. These errors lock the stream and disable the local transport endpoint. Only errno is set to the following value (t_errno is not affected):
During the period of the connection, SPX/SPXII uses the most recent round-trip delay multiplied by 1.5 as the timeout for the next retransmission.
The T_MORE flag is supported by SPX/SPXII.
/* ** SpxII will partition large messages into appropriately ** sized packets. */#define TRANS_BUFFER_SIZE 4096 int flags; int bytesRead; unsigned char readBuffer[TRANS_BUFFER_SIZE]; char *someFileString = "someFileName"; FILE *fp;
/* Open the file to send */ if ((fp=fopen(someFileString, "r+b")) == NULL) { perror("open failed "); ... }
/* While there is data in the file, tell the remote endpoint that ** there is still data for this transmission */ flags = T_MORE; while (!feof(fp)) { bytesRead=fread(readBuffer, 1, TRANS_BUFFER_SIZE, fp); /* ** spxFd2 is the local endpoint that has been bound and ** connected to a server */ if (t_snd(spxFd2, readBuffer, bytesRead, flags)<0) { t_error( "t_snd failed "); ... } ... }
/* Check that we haven't been cut off by remote end. NOTICE that the ** return code is greater than zero if we received a disconnect ** indication. */
if (t_rcvdis(spxFd2, &disconnectInfo)>=0) { printf( "remote endpoint aborted connection \n"); ... } /* Send one byte with the T_MORE flag turned off to indicate EOF */ flags = 0; if (t_snd(spxFd2, readBuffer, 1, flags)<0) { t_error( "t_snd failed "); ... }