problem parsing an int from IRC output.....

Luke Ordelmans l.ordelmans at student.utwente.nl
Wed May 14 18:33:33 EDT 2003


Hey all,

I'm trying to write a small program that can communicatie though IRC (dcc)..
I can connect to an irc server, send messages, but when i am invited to an
dcc, i have a problem..
I can cut the string i get in the needed pieces: IP and PORT...
but i fail trying to convert the PORT to int....

here's (a piece of) my code for this part:

if data.find("DCC CHAT chat") != -1:
        servip = data.__getslice__(len(data)-19, len(data)-9)
        servport = data.__getslice__(len(data)-8, len(data))  
        print("\tfrom IP: " + str(servip) )
        print("\tat port: " + str(servport) )
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.bind(("localhost", 9234))
        #server = ("localhost", servport)                       # FAILES
        #server = ("localhost", int(servport))                  # FAILES
        server = ("localhost", int(servport.strip()), 0)        # FAILES
        s.connect(server)

the error I get:

File "./FSStatus.py", line 28, in dataReceived
server = ("localhost",int(servport))
exceptions.ValueError: invalid literal for int(): 49369

Can anyone help me with this?

Luke Ordelmans




More information about the Python-list mailing list