summaryrefslogtreecommitdiff
path: root/README
blob: 920cb3a13ac980061b50a58f313975a94089214b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
===========
Quick links
===========

* Home page: http://code.google.com/p/pysendfile
* Download: http://code.google.com/p/pysendfile/downloads/list

=====
About
=====

A python interface to sendfile(2) system call.

=======
Install
=======

$ sudo setup.py install

...or:

$ easy_install pysendfile

===================
Supported platforms
===================

* Linux
* OSX
* FreeBSD
* Dragon Fly BSD
* SunOS
* AIX (non properly tested)

Python versions from 2.5 to 3.3 by using a single code base.

=============
Example usage
=============

::

    import socket
    import errno
    from sendfile import sendfile

    file = open("somefile", "rb")
    sock = socket.socket()
    sock.connect(("127.0.0.1", 8021))
    offset = 0

    while 1:
        try:
            sent = sendfile(sock.fileno(), file.fileno(), offset, 4096)
        except OSError, err:
            if err.errno == (errno.EAGAIN, errno.EBUSY):  # retry
                continue
            raise
        else:
            if sent == 0:
                break  # done
            offset += sent