I'm trying to save the incoming data of a udp transmission to a file. To avoid unnecessary overhead I want to use splice.

int sock;
//(...) socket initialization
FILE *myfile;
int mypipe[2];
if((myfile = fopen("test.txt","w"))== NULL){return;}

splice(sock, NULL, mypipe[1], NULL, buffersize, SPLICE_F_MOVE);
splice(mypipe[0], NULL, fileno(myfile), NULL, buffersize, SPLICE_F_MOVE);

Already the first call of splice ends with EINVAL.

Does anyone see what I'm doing wrong or isn't it possible to use splice on sockets?

I'm using Ubuntu 9.10, Kernel 2.6.31-22

Thank you very much in advance