Python Forum
How to use fcntl.ioctl() to get output buffer of socket after sendall() operation
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to use fcntl.ioctl() to get output buffer of socket after sendall() operation
#1
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??
Reply


Messages In This Thread
How to use fcntl.ioctl() to get output buffer of socket after sendall() operation - by apsaxena - Dec-09-2016, 12:44 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Shocked Question about sending escape characters by using sendall function (python2.7). lzfneu 1 3,138 May-29-2021, 09:26 AM
Last Post: Gribouillis
  struct.error: unpack requires a buffer of 14 bytes upasana 0 8,645 Apr-18-2018, 11:06 AM
Last Post: upasana
  UDP Socket: How to clear the buffer and ignore oldes messages Guybrush 3 28,366 Apr-26-2017, 02:06 PM
Last Post: Guybrush

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020