Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it
    Registrato dal
    Aug 2008
    Messaggi
    146

    [Python] Problema stringa socket

    Ho un problema.
    Se io creo una connessione così:
    codice:
    HOST = '127.0.0.1'    # The remote host
    PORT = 50000          # port used by the server job
    
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect((HOST, PORT))
    non ci sono problemi.

    Ma se la connessione la faccio prendendo i dati da input tastiera, allora mi da errore.
    codice:
    self.__b.setSIPAddr(raw_input("Insert the ip address of ftp server: "))
    self.__b.setIPort(raw_input("Insert the port number: "))
    .
    .
    .
    sIpServer = self.__b1.getSIPAddr()
    iPort = self.__b1.getIPort()
    self.__s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    self.__s.connect((sIpServer, iPort))
    L'errore è questo:

    self.__s.connect((sIpServer, iPort))
    File "<string>", line 1, in connect
    TypeError: coercing to Unicode: need string or buffer, NoneType found

    Credo sia da imputarsi al tipo di stringa usato ma non so come convertirlo, e devo assolutamente prendere i dati da input console.

  2. #2
    Il vaore "porta" deve essere di tipo intero (int) e non stringa (str) e quello che ti ritorna raw_input() è proprio una stringa.
    Convertilo in intero tramite int() prima di passarlo alla connect().
    Rilasciata Python FTP Server library 0.5.1
    http://code.google.com/p/pyftpdlib/

    We'll be those who'll make the italian folks know how difficult can be defecating in Southern California without having the crap flying all around the house.

  3. #3
    Utente di HTML.it
    Registrato dal
    Aug 2008
    Messaggi
    146
    Grazie ora funziona!!!

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.