0

I'm new to Android development, I'm developing FTP client application for Android.

I'm using FTP in active mode I running list command in active mode for which server has to open data port for sending list response. I'm testing my application in Eclipse emulator.

When I run list command it will give following error, failed to establish a connection.

I have some question regarding this

  1. Can we open data port in the emulator?
  2. if yes then it will open ports from development machine or in the emulator itself.

also kindly tell how to fix this problem any help and suggestion is greatly appreciated.

Roham Rafii
  • 2,929
  • 7
  • 35
  • 49
Arsalan
  • 1
  • 1
  • 1
  • Do u mean u can't connect internet from emulator ??? – Hein May 10 '11 at 03:50
  • no i connect to internet but but i cant run ftp "LIST" command.i want to run list command in active mode, FTp list comand succfully run in passive mode from my application. – Arsalan May 10 '11 at 03:54
  • In active mode server open a port on client and send it response to that port,but when server try to connect with this port this error occurs "Failed to established connection", hoply you understad what im trying to say :) – Arsalan May 10 '11 at 04:06

1 Answers1

1

Usually android emulator has different network with its own ip address and so on. For communicating with the server, when the server connects to development pc and issue the command, you need to redirect that to the port of the emulator.

Example:

  1. Server is connecting to emulator on port 1234
  2. Redirect the development machine port 1234 to emulator with the following commands
    in the command prompt
    C:> telnet localhost
    Ex: telnet localhost 5554 (Will be logged in to the emulator)
    ->redir add <tcp/udp>:hostport:emulatorport
    Ex: redir add udp:1234:1234 ->quit

For Ref: https://developer.android.com/studio/run/emulator-networking

Regards,
SSuman185

nulldroid
  • 1,150
  • 8
  • 15
Suman
  • 4,221
  • 7
  • 44
  • 64
  • These forwards only work for traffic originating inside the hosting machine because they do not listen on external interfaces. They do not work for traffic coming from remote servers - you would need a forwarding tool outside of the android emulator to accomplish that. – Chris Stratton Aug 15 '11 at 00:22
  • Reference link not available anymore. edit: alternative source here https://developer.android.com/studio/run/emulator-networking – nulldroid Sep 25 '20 at 15:46