Python Forum

Full Version: How to use fcntl.ioctl() to get output buffer of socket after sendall() operation
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am trying to get the pending data size in output buffer after calling my socket's sendall(). I am using TCP (non-blocking) socket in a class. My code for send message function in the class is as follows:
def send_data(self, msg):
    try:
        status_of_send = self.client.sendall(msg)
        buffer = array.array('I', [0])
        pending = fcntl.ioctl(self.tcp_socket.fileno(), termios.TIOCOUTQ, buffer, True)
        print pending
    except socket.error as e:
        print 'Error while sending data: %s', e
On calling to this function, an Error is occurring as follows:
TraceBack (most recent call last):
File "server.py", line 199, in send_date
pending = fcntl.ioctl(self.tcp_socket.fileno(), termios.TIOCOUTQ, buffer, True)
IOERROR: [Errno 22] Invalid argument
Can any one help me with this??