Search code examples
pythonsocketsproxyirc

connecting to a socket


         arg = data.split( )   

         args = '' 
         for index,item in enumerate(arg) : 
              if index > 3: 
                  if args == '': 
                      args = item 
                  else : 
                          args += ' ' + item


  if data.find('!check') != -1:
     nick = data.split('!')[ 0 ].replace(':','')
     s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     ip = args[1]
     port = int(args[2])
     try:
         s.connect((ip, port))
         s.send('PRIVMSG ' + chan + " :" ' its alive' + '\r\n')
     except socket.error:
         s.send('PRIVMSG ' + chan + " :" ' its dead' + '\r\n')

I'm trying to connect to a proxy to see if its alive or dead, but I keep getting this error..

port = int(args[2]) 
ValueError: invalid literal for int() with base 10: '.'

Solution

  • What arguments are you giving your code? The ValueError is telling you that you're trying to convert a period (.) to an integer, which makes no sense. What is args?