Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MacOS TCP_NODELAY error #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 6 additions & 4 deletions koheron/koheron.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import json
import requests
import time
import platform

from .version import __version__

Expand Down Expand Up @@ -257,10 +258,11 @@ def __init__(self, host='', port=36000, unixsock=''):
self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 16384)
so_rcvbuf = self.sock.getsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF)

# Disable Nagle algorithm for real-time response:
self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
tcp_nodelay = self.sock.getsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY)
assert tcp_nodelay == 1
# Disable Nagle algorithm for real-time response (unnecessary on MacOS)
if platform.system() != 'Darwin':
self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
tcp_nodelay = self.sock.getsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY)
assert tcp_nodelay == 1

# Connect to Kserver
self.sock.connect((host, port))
Expand Down