Forum Xamarin Xamarin.Android

Run Embedded FTP Server

TeHaTeHa DEMember ✭✭✭
edited November 2012 in Xamarin.Android

Hey folks,

I try to set up a ftp-server on a Android-device to synchronise data with a PC-program. Therefor I use this ftp-server
But there's a problem: If the client-side send a pasv-command, the server throws a SockedException with the Message: 'Access denied' (you can see full output in the atteched log-file)

for me it looks like the app couldn't create a new port at the device. but why?


  • JonathanPryorJonathanPryor USXamarin Team Xamurai

    What port is your server running on? FTP runs on port 21 by default, and Unix systems do not allow non-root users to open ports < port 1000. You may need to configure things to use a different port.

    Reading the source, I see that Assemblies.Ftp/FtpServer.cs does default to port 21 (line 52), though an alternate port can be specified by using FtpServer.Start(int).

  • TeHaTeHa DEMember ✭✭✭

    Yes, I know that. The default port is 21. But I tried also to open Port 1048, 1234 or 11000 but it never works and always canceled at the same position. By looking a bit deeper to the code you can see, that the CSFtp always uses port 21 for receiving commands (doesn't matter which port you specify with the start-method) and only uses the port given to the start-method for sending and receiving files. (which I think is correct)

    But I don't really know if I can choose another port for command-handling, but I would try it. If it doesn't work: how can I start my app as root-user? I don't have any experience with linux/unix.

  • JonathanPryorJonathanPryor USXamarin Team Xamurai

    how can I start my app as root-user?

    If you're dealing with a non-rooted (i.e. "normal") device, you don't. (Note: emulators allow root access, but I'm not sure I'd call the emulators "normal"...)

    If you've rooted your phone, I assume that it's possible to run arbitrary apps as the root user, but I don't know how to do so.

  • TeHaTeHa DEMember ✭✭✭

    Hi folks, I found the reason the server does not run:

    It was starting a new TcpListener (in a new thread) during the initialisation. So the server receives the PASV command but the original thread never answers (at least I think that was the mistake). Now I handle all commands in one TcpListener.
    And I start the server with a port > 10,000

Sign In or Register to comment.