Hello,
Thanks.
I use 2.6.11-1 kernel ,Fedora Core 4.
Here is the program I use and the error I get after
I send one UDP packet to this machine on the port it listens on ,9000.
(Note : input.txt is a nonempty small input file.)
#include <sys/sendfile.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>
#define MAXBUF 1024
int main()
{
int ret;
int port = 9000;
int sock;
int fdSockOut=-1;
int fdFileIn;
int addrlen;
struct stat stat_buf;
char buf[MAXBUF];
struct sockaddr_in addr;
struct sockaddr_in udpClient;
off_t offset = 0;
memset(&addr,0,sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = INADDR_ANY;
addr.sin_port = htons(port);
sock = socket(AF_INET,SOCK_DGRAM,0);
if (sock == -1)
{
printf("cannot open socket\n");
exit(1);
}
ret = bind(sock,(struct sockaddr*)&addr,sizeof(addr));
if (ret == -1)
{
printf("could not bind\n");
exit(1);
}
ret = recvfrom(sock,buf,MAXBUF,0,
(struct sockaddr*)&udpClient,&addrlen);
printf("after recvFrom\n");
fdFileIn= open("input.txt",O_RDONLY);
if (fdFileIn == -1)
{
printf("cannot open file\n");
exit(1);
}
// get the size of the file
fstat(fdFileIn,&stat_buf);
ret = sendfile(sock,fdFileIn,&offset,stat_buf.st_size);
if (ret == -1)
{
perror("sendfile");
printf("errno=%d\n",errno);
}
else
{
printf("sendfile succeeded\n");
}
}
The error get is:
errno = ESPIPE
sendfile: Destination address required
Regards,
JQ
On 11/8/05, Ian McDonald <[EMAIL PROTECTED]> wrote:
> > But when I am trying to write a user space program
> > which tries using sendfile with
> > UDP sockets I encounter erros. (with TCP sockets
> > sendfile works OK).
> >
> If you want help you need to supply more information. Please supply a
> small sample program and also the error messages. You should also
> supply what version of the kernel you are working on too.
>
> I would also suggest that it may be more appropriate to send your
> question to linux-net mailing list as this list for kernel networking
> developers. However you may have a genuine bug here but we can't tell
> yet.
>
> Ian
>
> --
> Ian McDonald
> http://wand.net.nz/~iam4
> WAND Network Research Group
> University of Waikato
> New Zealand
>
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html