Function:
sendfile(out_fd, in_fd, offset, count)
Overview:
- The sendfile() function copies the contents of one file to another file, using their descriptors.
Parameters:
out_fd - The descriptor of the destination file
in_fd - The descriptor of the source file
offset - Offset from where the contents need to be copied from the source
count - Number of bytes to be copied
Return Value:
None
Example Client Program:
# Example client program that sends the text of a song # The file to be sent and its descriptor # Create a client connection # In macOS, a zero value for the count means |
Output:
b'The wheels on the bus go round and round' |
Example - Server Program:
# Example server program that sends # Create a streaming server socket(i.e,TCP server) that ip = "127.0.0.1" # Listen for connection requests # Serve connection requests while(True): |
Output:
Server socket created |