lsalzman/enet — pull request #17 by benoit-germain (2013-05-04 06:43:51+00:00)
Title: Proof of concept for large data transfer utility to send large amount of data between two hosts.

Usage:

Two connected hosts first agree on a channel to send the data through. They can do this any way they choose.

Once an agreement is reached, the receiving end is responsible for handling any data received in that channel.
On the sending side, a data job is created with enet_host_register_datajob(). The function receives, among other things, a callback that provides data.

The callback returns the amount of data written, and should return 0 when done. The callback receives a buffer pointer to write the data to. When the pointer is null, either the jobs has been cancelled or the job has completed. IT is then time to perform any necessary cleanup.

Cleanup on the receiving side is application dependant. For example, during channel negocation, the sender might provide the amount of data it wants to transfer. Then on the receiving end, a file where received data is stored should be closed when the receiver detects it has received the specified amount.

The sending application must also call enet_host_process_datajobs() when it knows jobs are registered (usually do this at the same time as enet_host_service).