#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    1
    Rep Power
    0

    Question Whats wrong with this? need help..


    Hello!
    I'm trying to make a little code who connects to IRC.

    whats wrong? and what am I missing?
    Thanks!

    Dagan

    Code:
    '''
    trying to make a IRC client,
    getting "type error: 'module' object is not callable" in
    line 16:
    sock = socket(socket.AF_INET, socket.SOCK_STREAM)
    '''
    
    import socket
    port = 6667
    server = "eu.undernet.org"
    channel = "#TestChan"
    
    
    class IRCClass:
        def __init__(self):
            sock = socket(socket.AF_INET, socket.SOCK_STREAM)
            self.bind((port, server))
    
        def connect(self):
            sock.connect()
            try:
                self.recieve()
                
            except:
                return "Something failed."
    
        def recieve(self):
            line = self.sock.recv(byte)
            return line
    
    
    
    
    irc = IRCClass()
    irc.connect(port, server)
    irc.byte = 1024
    irc.recv()
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2004
    Location
    Canada
    Posts
    242
    Rep Power
    0
    You need to use

    Code:
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    instead.

    What you are doing now is trying to call the module, not the "socket" function.

IMN logo majestic logo threadwatch logo seochat tools logo