10049 can't assign requested address

711 views
Skip to first unread message

janko.s...@gmail.com

unread,
Jul 8, 2011, 9:42:06 AM7/8/11
to pyft...@googlegroups.com
#!/usr/bin/env python
  
import os, re
import time
import urllib2
  
from pyftpdlib import ftpserver
  

now = lambda: time.strftime("[%Y-%b-%d %H:%M:%S]")
  
def standard_logger(msg):
    f1.write("%s %s\n" %(now(), msg))
    print msg
  
def line_logger(msg):
    f2.write("%s %s\n" %(now(), msg))
    print msg  
   
   
if __name__ == "__main__":
    f1 = open('ftpd.log', 'a')
    f2 = open('ftpd.lines.log', 'a')
    ftpserver.log = standard_logger
    ftpserver.logline = line_logger
   

    f = urllib2.urlopen('http://www.showmemyip.com/')
    data = f.read()


    ip = re.search('<span id="IPAddress">.+</span>', data)
    ip = ip.group(0)
    ip = re.sub('<span id="IPAddress">', '', ip)
    ip = re.sub('</span>', '', ip)
   
   
    print ip
    #file = open('ip.txt')
    #ip = file.read()
         
    authorizer = ftpserver.DummyAuthorizer()
    authorizer.add_user('username', 'password', os.getcwd(), perm='elradfmw')
    #authorizer.add_anonymous(os.getcwd())
    ftp_handler = ftpserver.FTPHandler
    ftp_handler.authorizer = authorizer
    ftp_handler.banner = "Welcome"
    address = (ip, 21)
    ftpd = ftpserver.FTPServer(address, ftp_handler)
    ftpd.serve_forever()



93.137.127.244
Traceback (most recent call last):
  File "", line 50, in <module>
    ftpd = ftpserver.FTPServer(address, ftp_handler)
  File "C:\Python25\lib\site-packages\pyftpdlib\ftpserver.py", line 3385, in __init__
    raise socket.error(msg)
socket.error: (10049, "Can't assign requested address")


i have the last pyftpdlib, python 2.5.4 and on windows xp.
it does work on the localhost. i tried to disable the firewall. 
i've got a Thomson TG782(i) if it means something.

Giampaolo Rodolà

unread,
Jul 8, 2011, 9:50:51 AM7/8/11
to pyft...@googlegroups.com
The error is clear: you have no network interface with address 93.137.127.244.
On Windows you can check your network interfaces by using "ipconfig
/all" command from the command prompt.

Regards,

Giampaolo

2011/7/8 <janko.s...@gmail.com>:

> --
> You received this message because you are subscribed to the "Python FTP
> server library" project group:
> http://code.google.com/p/pyftpdlib/
> To post to this group, send email to pyft...@googlegroups.com
> To unsubscribe from this group, send email to
> pyftpdlib-...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/pyftpdlib

Sebastian Janko

unread,
Jul 8, 2011, 9:57:47 AM7/8/11
to Python FTP server library - Discussion group
ok, true, it's not shown there. but that's the ip of the computer on
the internet.
in ipconfig i get the ip address as 192.168.1.22 :/

Windows IP Configuration

Host Name . . . . . . . . . . . . : comp
Primary Dns Suffix . . . . . . . :
Node Type . . . . . . . . . . . . : Unknown
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
DNS Suffix Search List. . . . . . : lan

Ethernet adapter Local Area Connection:

Connection-specific DNS Suffix . : lan
Description . . . . . . . . . . . : Realtek PCIe FE Family
Controller
Physical Address. . . . . . . . . : 20-CF-30-90-0A-9E
Dhcp Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
IP Address. . . . . . . . . . . . : 192.168.1.22
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.1.1
DHCP Server . . . . . . . . . . . : 192.168.1.1
DNS Servers . . . . . . . . . . . : 192.168.1.1
Lease Obtained. . . . . . . . . . : 8. srpanj 2011 8:53:58
Lease Expires . . . . . . . . . . : 9. srpanj 2011 8:53:58



On Jul 8, 3:50 pm, Giampaolo Rodolà <g.rod...@gmail.com> wrote:
> The error is clear: you have no network interface with address 93.137.127.244.
> On Windows you can check your network interfaces by using "ipconfig
> /all" command from the command prompt.
>
> Regards,
>
> Giampaolo
>
> 2011/7/8  <janko.sebast...@gmail.com>:

Giampaolo Rodolà

unread,
Jul 8, 2011, 10:01:17 AM7/8/11
to pyft...@googlegroups.com
Who is 93.137.127.244? A client?
pyftpdlib is a server: you have to bind it to a *local* network interface.

Regards,

--- Giampaolo

Sebastian Janko

unread,
Jul 8, 2011, 10:06:28 AM7/8/11
to Python FTP server library - Discussion group
i remember that i could bind it to the global (if it isn't local) ip
address, like the one i was trying to.

but tnx, and keep up the good work

Giampaolo Rodolà

unread,
Jul 8, 2011, 10:10:40 AM7/8/11
to pyft...@googlegroups.com
Use an empty string "" as the address and you should be ok.
Also, you should set the public IP address of your NAT by using
FTPHandler.masquerade_address directive otherwise passive connections
won't work:
http://code.google.com/p/pyftpdlib/wiki/FAQ#I'm_behind_a_NAT_/_gateway

See this for an example usage:
http://code.google.com/p/pyftpdlib/source/browse/trunk/demo/basic_ftpd.py

Ciao,

Giampaolo

2011/7/8 Sebastian Janko <janko.s...@gmail.com>:

Reply all
Reply to author
Forward
0 new messages