| 930 | _sendfile_compatible = constants._SendfileMode.TRY_NATIVE |
| 931 | |
| 932 | def __init__(self, loop, sock, protocol, waiter=None, |
| 933 | extra=None, server=None): |
| 934 | |
| 935 | self._read_ready_cb = None |
| 936 | super().__init__(loop, sock, protocol, extra, server) |
| 937 | self._eof = False |
| 938 | self._empty_waiter = None |
| 939 | if _HAS_SENDMSG: |
| 940 | self._write_ready = self._write_sendmsg |
| 941 | else: |
| 942 | self._write_ready = self._write_send |
| 943 | # Disable the Nagle algorithm -- small writes will be |
| 944 | # sent without waiting for the TCP ACK. This generally |
| 945 | # decreases the latency (in some cases significantly.) |
| 946 | base_events._set_nodelay(self._sock) |
| 947 | |
| 948 | self._loop.call_soon(self._protocol.connection_made, self) |
| 949 | # only start reading when connection_made() has been called |
| 950 | self._loop.call_soon(self._add_reader, |
| 951 | self._sock_fd, self._read_ready) |
| 952 | if waiter is not None: |
| 953 | # only wake up the waiter when connection_made() has been called |
| 954 | self._loop.call_soon(futures._set_result_unless_cancelled, |
| 955 | waiter, None) |
| 956 | |
| 957 | def set_protocol(self, protocol): |
| 958 | if isinstance(protocol, protocols.BufferedProtocol): |