From f6875352b0a3761ba0057b57e21c2d21057ecec9 Mon Sep 17 00:00:00 2001 From: Beat Bolli Date: Wed, 25 Dec 2013 15:28:06 +0100 Subject: [PATCH] irk: reuse the already connected socket Signed-off-by: Eric S. Raymond --- irk | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/irk b/irk index 6b35826..0e88a1a 100755 --- a/irk +++ b/irk @@ -12,11 +12,10 @@ import socket import sys import fileinput -def send(target, message): +def send(s, target, message): data = {"to": target, "privmsg" : message} #print(json.dumps(data)) try: - s = socket.create_connection(("localhost", 6659)) s.sendall(json.dumps(data)) except socket.error, e: sys.stderr.write("irk: write to server failed: %r\n" % e) @@ -33,6 +32,6 @@ message = " ".join(sys.argv[2:]) message = message.decode('string_escape') if message == '-': for line in fileinput.input('-'): - send(target, line.rstrip('\n')) + send(s, target, line.rstrip('\n')) else: - send(target, message) + send(s, target, message) -- 2.26.2