

#include <sys/types.h>
#include <sys/uio.h>
int writev (int fd, struct iovec iov[],
int iovcount);
int readv (int fd, struct iovec iov[],
int iovcount);
struct iovec {
void *iov_base;
int iov_len;
};
int write_with_hdr (int fd, void *buff, int nBytes)
{
struct hdr header;
/* set up header ... as required */
if (write(fd, &header, sizeof(header)) !=
sizeof(header)) {
return( -1 );
}
if (write(fd, buff, nBytes) == nBytes) {
return( nBytes );
} else {
return( -1 );
}
}
int write_with_hdr (int fd, void *buff, int nBytes)
{
struct hdr header;
struct iovec iov[2];
/* set up header ... as required */
iov[0].iov_base = (void *)&header;
iov[0].iov_len = sizeof(header);
iov[1].iov_base = buff;
iov[1].iov_len = nBytes;
if (writev(fd, &iov, 2) ==
sizeof(header) + nBytes) {
return( nBytes );
} else {
return( -1 );
}
}

char myowndata[lengthOfData] ;
nbytes = write(tcpSocket, &myowndata,
lengthOfData);
}



This document was produced using groff-1.19.