Commits

Ryan Williams  committed 5dc37b1

Added flags argument to send and recv variants, for completeness.

  • Participants
  • Parent commits 9f24765

Comments (0)

Files changed (1)

File eventlet/greenio.py

 __all__ = ['GreenSocket', 'GreenFile', 'GreenPipe']
 
 def higher_order_recv(recv_func):
-    def recv(self, buflen):
+    def recv(self, buflen, flags=0):
         if self.act_non_blocking:
-            return self.fd.recv(buflen)
+            return self.fd.recv(buflen, flags)
         buf = self.recvbuffer
         if buf:
             chunk, self.recvbuffer = buf[:buflen], buf[buflen:]
             return chunk
         fd = self.fd
-        bytes = recv_func(fd, buflen)
+        bytes = recv_func(fd, buflen, flags)
         if self.gettimeout():
             end = time.time()+self.gettimeout()
         else:
                 else:
                     raise
             else:
-                bytes = recv_func(fd, buflen)
+                bytes = recv_func(fd, buflen, flags)
         self.recvcount += len(bytes)
         return bytes
     return recv
 
 
 def higher_order_send(send_func):
-    def send(self, data):
+    def send(self, data, flags=0):
         if self.act_non_blocking:
-            return self.fd.send(data)
-        count = send_func(self.fd, data)
+            return self.fd.send(data, flags)
+        count = send_func(self.fd, data, flags)
         if not count:
             return 0
         self.sendcount += count
         raise
 
 
-def socket_send(descriptor, data):
+def socket_send(descriptor, data, flags=0):
     try:
-        return descriptor.send(data)
+        return descriptor.send(data, flags)
     except socket.error, e:
         if e[0] == errno.EWOULDBLOCK or e[0] == errno.ENOTCONN:
             return 0
 
 # winsock sometimes throws ENOTCONN
 SOCKET_CLOSED = (errno.ECONNRESET, errno.ENOTCONN, errno.ESHUTDOWN)
-def socket_recv(descriptor, buflen):
+def socket_recv(descriptor, buflen, flags=0):
     try:
-        return descriptor.recv(buflen)
+        return descriptor.recv(buflen, flags)
     except socket.error, e:
         if e[0] == errno.EWOULDBLOCK:
             return None
         raise
 
 
-def file_recv(fd, buflen):
+def file_recv(fd, buflen, flags=0):
     try:
         return fd.read(buflen)
     except IOError, e:
         raise
 
 
-def file_send(fd, data):
+def file_send(fd, data, flags=0):
     try:
         fd.write(data)
         fd.flush()
 
     send = higher_order_send(socket_send)
 
-    def sendall(self, data):
+    def sendall(self, data, flags=0):
         fd = self.fd
-        tail = self.send(data)
+        tail = self.send(data, flags)
         while tail < len(data):
             trampoline(self.fd, write=True, timeout_exc=socket.timeout)
-            tail += self.send(data[tail:])
+            tail += self.send(data[tail:], flags)
 
     def sendto(self, *args):
         trampoline(self.fd, write=True, timeout_exc=socket.timeout)