well, I think I am almost there.... I think....
I have to compilation errors based of the structs being created, however, since I using the examples from the senfile man page to base my function off of, I am bit confused as to why the compiler is unhappy.
here is the function:
Code:
int Sndfl ()
{
int ffd, tfd;
off_t off;
struct sockaddr_in sin;
in_addr_t addr;
int len;
struct stat stat_buf;
ffd = open(BARCODE_TABLE, O_RDONLY);
if (ffd == -1) {
perror("open");
exit(1);
}
tfd = socket(AF_INET, SOCK_STREAM, 0);
if (tfd == -1) {
perror("socket");
exit(1);
}
sin.sin_family = AF_INET;
sin.sin_addr = INADDR_ANY; /* Fill in the appropriate address. */
sin.sin_port = htons(1130);
if (connect(tfd, (struct sockaddr *) &sin, sizeof(sin)) <0) {
perror("connect");
exit(1);
}
if (fstat(ffd, &stat_buf) == -1) {
perror("fstat");
exit(1);
}
len = sendfile(tfd, ffd, &off, stat_buf.st_size);
if (len == -1) {
perror("sendfile");
exit(1);
}
}
Here are my errors
Code:
utilserv.c: In function `Sndfl':
utilserv.c:115: error: storage size of `stat_buf' isn't known
utilserv.c:130: error: incompatible types in assignment
I am guessing that I have not used this example properly and did not tell the compiler how much buffer space to give stat_buf??
Again, thanks for any help available.