Skip to content

Commit

Permalink
Setting larger buffer size for faster transfers with less overhead
Browse files Browse the repository at this point in the history
  • Loading branch information
morphex committed Jul 30, 2022
1 parent 198ff1c commit 5e477bf
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions run.py
Expand Up @@ -12,6 +12,7 @@
threading.stack_size(4096 * 8)

EMPTY_BYTES = bytes()
BUFFER_SIZE = 4096 * 8

try:
max_active_connections = int(sys.argv[5])
Expand Down Expand Up @@ -78,7 +79,7 @@ def setup(self):

def handle(self):
DEBUG_PRINT("Start of handle")
global EMPTY_BYTES
global EMPTY_BYTES, BUFFER_SIZE
if not self._activated:
global connection_queue
connection_queue.add(self)
Expand All @@ -99,7 +100,7 @@ def handle(self):
while True:
fall_through = False
try:
to_proxy = user_s.recv(4096, socket.MSG_DONTWAIT)
to_proxy = user_s.recv(BUFFER_SIZE, socket.MSG_DONTWAIT)
except ConnectionResetError:
quit = 1
except BlockingIOError:
Expand All @@ -112,7 +113,7 @@ def handle(self):
proxy_s.send(to_proxy)
to_proxy = EMPTY_BYTES
try:
to_user = proxy_s.recv(4096, socket.MSG_DONTWAIT)
to_user = proxy_s.recv(BUFFER_SIZE, socket.MSG_DONTWAIT)
except ConnectionResetError:
quit = 1
except BlockingIOError:
Expand Down

0 comments on commit 5e477bf

Please sign in to comment.