Michael Felt <aixto...@felt.demon.nl> added the comment:
OK. Couple of months later. Would appreciate guidance before submitting a patch. In advance: Thank you for your time and consideration. Short: socket.sendfile() and AIX send_file() are very close in terms of functionality - especially the requirement that "out_fd" is a non-blocking socket. os.sendfile() and AIX send_file(), imho, do not match because it appears that os.sendfile(in_fd, out_fd, ...) will work with any kind of open file descriptor. Longer: .. method:: socket.sendfile(file, offset=0, count=None) Send a file until EOF is reached by using high-performance :mod:`os.sendfile` and return the total number of bytes which were sent. *file* must be a regular file object opened in binary mode. If :mod:`os.sendfile` is not available (e.g. Windows) or *file* is not a regular file :meth:`send` will be used instead. ... The socket must be of :const:`SOCK_STREAM` type. Non-blocking sockets are not supported. .. versionadded:: 3.5 AIX #include < sys/socket.h > ssize_t send_file(Socket_p, sf_iobuf, flags) int * Socket_p; struct sf_parms * sf_iobuf; uint_t flags; Description The send_file subroutine sends data from the opened file specified in the sf_iobuf parameter, over the connected socket pointed to by the Socket_p parameter. Note Currently, the send_file only supports the TCP/IP protocol (SOCK_STREAM socket in AF_INET). An error will be returned when this function is used on any other types of sockets. **** These match in terms of goals. **** Considering the requirements of AIX send_file() os.sendfile() does not seem to fit. I read (Doc/library/os.rst) os.sendfile to imply that any open file descriptors will be "sent" whereas with socket.sendfile - in_fd is binary file, out_fd is a SOCK_STREAM socket descriptor. So, would like some feedback on how to proceed: e.g., A. a new os.send_file - only available for AIX (and only accessible to socket.sendfile(), B. os.sendfile "returns" one of the following when the input parameters are not appropriate: EBADF Either the socket or the file descriptor parameter is not valid. ENOTSOCK The socket parameter refers to a file, not a socket. (There are other errno results, not important for the discussion atm). Again, thank you for your time! ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue37336> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com