Commits

keliaakikkoman committed 1ecc740

idiokit.socket & idiokit.xmpp: Implemented idiokit.socket.Socket.getsockopt and .setsockopt. XMPP connections now set the TCP_NODELAY flag for sockets.

Comments (0)

Files changed (2)

idiokit/socket.py

             result = yield _send(self._socket, timeout, self._socket.sendto, string, flags, address)
         idiokit.stop(result)
 
+    @idiokit.stream
+    def getsockopt(self, *args, **keys):
+        yield timer.sleep(0)
+
+        with wrapped_socket_errors():
+            result = self._socket.getsockopt(*args, **keys)
+        idiokit.stop(result)
+
+    @idiokit.stream
+    def setsockopt(self, *args, **keys):
+        yield timer.sleep(0)
+
+        with wrapped_socket_errors():
+            result = self._socket.setsockopt(*args, **keys)
+        idiokit.stop(result)
+
     # Not implemented:
     # connect_ex: Use connect(...)
     # recv_into, recvfrom_into: Use recv(...) and recvfrom(...)
     # setblocking, settimeout, gettimeout: Use Socket.<method>(..., timeout=<seconds>)
-    # ioctl, getsockopt, setsockopt
+    # ioctl
     # fileno, makefile
 
 class Socket(_Socket):

idiokit/xmpp/__init__.py

             continue
 
         try:
+            yield sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
             yield sock.connect(addr)
         except socket.SocketError as error:
             yield sock.close()