Python WinError 10038 An operation was attempted on something that is not a socket

Viewed 43

I am trying to create python irc bot and the recv command gives the error. This is just what i wrote upto. Thanks in advance

import math
import socket
import time

server = b"irc.freenode.net"
port = 6667
channel = b"##testchannel"

irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print(b"connecting to:" + server)
irc.connect((server, port))
irc.send(b"NICK Av5h\n")
irc.send(b"JOIN " + channel + b"\n")


while 1:
    text = irc.recv(2040)
    print(text)

    if text.find(b'PING') != -1:
        irc.send(b'PONG ' + text.split()[1] + b'\r\n')
0 Answers
Related