Permalink
Browse files

TCP_NODELAY for better latency

  • Loading branch information...
1 parent 06063ca commit e921a1415ef58920847a4980960f29ba46400315 @paolo-losi committed Jan 10, 2011
Showing with 4 additions and 3 deletions.
  1. +3 −1 stormed/connection.py
  2. +1 −2 stormed/frame.py
@@ -38,7 +38,9 @@ def connect(self, callback):
if self.status is not status.CLOSED:
raise Exception('Connection status is %s' % self.status)
self.status = status.OPENING
- self.stream = IOStream(socket.socket(), io_loop=self.io_loop)
+ sock = socket.socket()
+ sock.setsockopt(socket.SOL_TCP, socket.TCP_NODELAY, 1)
+ self.stream = IOStream(sock, io_loop=self.io_loop)
self.stream.connect((self.host, self.port), self._handshake)
self.stream.set_close_callback(self.on_closed_stream)
self.on_connect = callback
View
@@ -167,8 +167,7 @@ def write_msg(self, msg):
frames = []
frames.append(content_header_from_msg(msg, self.channel_id))
frames.extend(body_frames_from_msg(msg, self.channel_id))
- for f in frames:
- self.conn.stream.write(f)
+ self.conn.stream.write(''.join(frames))
def hard_reset(self):
self.status = status.CLOSED

0 comments on commit e921a14

Please sign in to comment.