Regarding TCP connections to/from remote systems on Emulator

578 views
Skip to first unread message

Ash

unread,
Sep 1, 2009, 2:16:43 AM9/1/09
to android-ndk
I am developing a socket based UDP/TCP client/server native
application on Emulator. Using the examples, and the messages on the
Android mailing list I could setup the following communication

1. between Android UDP Client/Server and Remote UDP Client/Server
2. between Android TCP Client and Remote TCP Server – by setting the
Linux environment variable http_proxy=<remote TCP server ipaddr:port>

I know that item “2” above is just a hack and it limits the connection
to only one TCP server at a time, however, I could not find any other
work around for the same.

Has somebody successfully tested the following connection scenario on
emulator? If yes, kindly let me know the steps (what IP for listening/
connecting etc)

1. between Android TCP Client and Remote TCP Server – without setting
http_proxy
2. between Android TCP Server and Remote TCP Client – without setting
http_proxy

FYI, I am doing “redir add” through telnet for the required ports, I
am not doing any ssh port forwarding and I have only one Emulator
running all the time.

Thanks,
Ash

David Turner

unread,
Sep 1, 2009, 2:30:58 PM9/1/09
to andro...@googlegroups.com
A client in the emulator should be able to connect to any arbitrary TCP server,
barring DNS issues. What exact error do you get when you try that? which socket-related call fails ?
what does errno returns ? Did you try using the -tcpdump <file> option when starting the emulator
(or the corresponding "net capture start <file>" console command) to see what happens on the
emulated network, and analyze the trace with WireShark?

Ash

unread,
Sep 7, 2009, 8:59:57 AM9/7/09
to android-ndk
Thanks David for replying. It was my mistake I missed to check the
environment variable http_proxy because of which all TCP connections
that were initiated from Android try to connect to the $http_proxy
value(which is perfectly fine as per the documentation). I just unset
http_proxy and it started working fine. No port forwarding,
redirection etc are required for initiating a TCP connection (TCP
connect) to any arbitrary TCP server.

Now, I am trying to establish a connection to a TCP server running on
Android from a TCP client running on windows machine. I tried the
following -
Android TCP Server - Listening on 10.0.2.15:8767, redir add tcp:
8767:8767

Windows TCP Client - connect to <Android Host Machine Ubuntu IP
Address>:8767

The above setup does not work. I think SSH forwarding is required
between Windows system and Android Host Ubuntu system, but I don't
have any clue how to proceed. Kindly help me

Thanks,
Ash




On Sep 1, 11:30 pm, David Turner <di...@android.com> wrote:
> A client in the emulator should be able to connect to any arbitrary TCP
> server,barring DNS issues. What exact error do you get when you try that?
> > Ash- Hide quoted text -
>
> - Show quoted text -

David Turner

unread,
Sep 8, 2009, 9:16:12 AM9/8/09
to andro...@googlegroups.com
You should connect to localhost:8767 on the host machine. The emulator redirection only
listens on the loopback interface.

Tim Hutt

unread,
Sep 8, 2009, 10:34:43 AM9/8/09
to andro...@googlegroups.com
>> The above setup does not work. I think SSH forwarding is required
>> between Windows system and Android Host Ubuntu system, but I don't
>> have any clue how to proceed. Kindly help me

Yep, you can use putty to do ssh port forwarding on windows, or 'ssh' on linux.

From the windows machine:

1. Start putty, put in the ip address of the android host.
2. Go to connection->ssh->tunnels
3. Get confused! I believe I've got it to work in the past for vnc by
typing localhost:8767 into both the 'source port' and 'destination'
edit boxes and then clicking add. You might need to experiment with
the local/remote/dynamic thing.
4. You should be able to connect from your windows machine to its own
port 8767, and putty will forward the connection to port 8767 on the
linux system.

Reply all
Reply to author
Forward
0 new messages