1

I have to implement zero copy method in a program in Qt C++,I read about it and got transferto() method.as described below: public void transferTo(long position, long count, WritableByteChannel target);

but i can't understand how it works.It is written that Internally, it depends on the underlying operating system's support for zero copy. So I tried to write a function but i didn't get the meaning of "position" and "channel" here.

Can anyone help me?

Satya Kumar
  • 179
  • 1
  • 4
  • 19

1 Answers1

4

There is no cross-platform way to do zero copy in C++, and there is no zero-copy API in Qt. You can implement it for your target OS using provided API:

Linux supports zero copy through system calls such as sys/socket.h's sendfile, sendfile64, and splice. Windows supports zero copy through the TransmitFile API.

Source

Pavel Strakhov
  • 39,123
  • 5
  • 88
  • 127
  • that means i have to write a function to copy data in socket buffer to my intended place.and can u explain me the transferto() function i.e what is channel and position here so that i can implement my own function. – Satya Kumar Jun 14 '13 at 11:59
  • Please refer to the mentioned APIs' documentation. I'm not familiar with them. – Pavel Strakhov Jun 14 '13 at 12:06
  • Unfortunately `TransmitFile` only works between a handle and a network socket. It'd be cool if you could use it for copying files between non-network devices, or moving data between pipes, etc, but that's alas not the case :( – Kuba hasn't forgotten Monica Aug 21 '15 at 14:54