--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.
Hi Van,
Thanks for pointing out the exact mistake i was making.
I put the internet permission in manifest file and the socket creation
worked fine.
But now it is failing at the next stage, bind.
I am working on android emulators. So i have used my desktop's IP
address for socket binding. The code snippet is:
my_addr.sin_family = AF_INET;
my_addr.sin_port = htons(MYPORT);
my_addr.sin_addr.s_addr = /*INADDR_ANY*/
inet_addr("desktop IP address");
memset(&(my_addr.sin_zero), 0, 8);
bind(sockfd, (struct sockaddr *)&my_addr,
sizeof(struct sockaddr));
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
Hi David,
Thanks for the reply.
I tried with
bind(sockfd, (struct sockaddr *)&my_addr, sizeof(structsockaddr_in))
but not yet successful.
If I try with INADDR_ANY, then it is binding. In this case, is there
any way to know which address to connect from client?
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
Hi,
Sorry for late reply.
Thanks for the documentation link. It helped in understanding the
procedure better.
However, still there is no success in connecting from client to
server. I believe I have followed all the steps mentioned in the
documentation, but it is failing to connect.
I will briefly tell the procedure i am following.
1. run the server in 1st emulator. set the server to listen at
10.0.2.15:6000 --> listen is successful
2. run telnet and do: redir add tcp:5000:6000 --> redirect device port
5000 to emulator port 6000
3. run client in 2nd emulator in the same device and try to connect to
10.0.2.2:5000 --> connect gives timeout error
there is no error shown in accept() in the server side.
This IP addresses are suggested in the documentation, i am not sure
about the details behind it.
I think, there is some mismatch in the IP address and port server is
listening and client is trying to connect.
can anybody suggest some corrections?
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
On Wed, Sep 22, 2010 at 16:26, vick.s <souvic...@gmail.com> wrote:Hi,
Sorry for late reply.
Thanks for the documentation link. It helped in understanding the
procedure better.
However, still there is no success in connecting from client to
server. I believe I have followed all the steps mentioned in the
documentation, but it is failing to connect.
I will briefly tell the procedure i am following.
1. run the server in 1st emulator. set the server to listen at
10.0.2.15:6000 --> listen is successful
2. run telnet and do: redir add tcp:5000:6000 --> redirect device port
5000 to emulator port 6000
3. run client in 2nd emulator in the same device and try to connect to
10.0.2.2:5000 --> connect gives timeout error
there is no error shown in accept() in the server side.
This IP addresses are suggested in the documentation, i am not sure
about the details behind it.
I think, there is some mismatch in the IP address and port server is
listening and client is trying to connect.
can anybody suggest some corrections?As David suggests, test first with "telnet localhost 5000" from your desktop. This should end up at the server on the first emulator.In your second emulator, you should connect to your *desktop ip*, port 5000 - not 10.0.2.2. The two emulator images don't have any secret network between them (unless you play with qemu options), so the second emulator has to go out to your desktop, and then hit the 5000->emulator:6000 port forwarder in order to get back in to Android on the first emulator.
not true, 10.0.2.2 is always mapped to 127.0.0.1 on the development machine. Besides, the network redirection you setup will make the emulator listen for connection attemps on 127.0.0.1 too. This is an intentional security measure.
hi guys,
yes i have tried telnet localhost 5000
it is connecting to the server. accept is successful. recv is also
working
but client is not able to connect.
i tried to connect to my desktop IP too from client. But no result :(
also i tried to connect directly to 127.0.0.1 from client. failed :(
This is my client code:
addr.sin_family = AF_INET;addr.sin_addr.s_addr = htonl("10.0.2.2");
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.