I seem to be running into a wall when trying to receive large amounts of messages in a very short amount of time. I'm unsure if it is a limitation with python 3's networking protocols or it is a way that I have gone about receiving the data. Below I have posted the code on how I receive messages if it isn't a python issue.
How I have tested this I have wrote a script to send 10 messages in 1 second and I saw 60% of these messages. How would I fix this problem if this is a coding error?
# ------ Constructor ----- #
def __init__(self, conf): #constructor
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# ------ Connect Function ----- #
def connect(self):
self.sock.connect(("irc.twitch.tv", 6667))
self.sock.send(("PASS %s\n\r" % self.oauth).encode("utf-8"))
self.sock.send(("NICK %s\n\r" % self.username).encode("utf-8"))
self.sock.send("TWITCHCLIENT 2\n\r".encode("utf-8"))
self.sock.send(("JOIN #%s\n\r" % self.channel).encode("utf-8"))
# -------- Receive ------- #
def receive(self):
data = self.sock.recv(4096)
data = data.decode("utf-8")
if 'PING' in data:
self.sock.send(data.replace('PONG', 'PING').encode("utf-8"))
return data
It was not a python limitation it was the way I was tokenizing messages.