I have the client socket written in Android and the server is written in C. I am running the C server from my machine using cygwin. The client is running on the emulator in the same machine. Now I am using java.net.Socket in the client to establish the TCP connection. In the socket I have mentioned my machine's ip address and the server is listening to port 10001 so I have mentioned the port number as 10001.
I retrieved my machine's ip by the following steps. In the command prompt I entered ipconfig and what ever ip listed there, I mentioned the same address in the client socket.
I also modified the manifest file and set the internet permission.
So now when I start the server using cygwin and then run the android application from Eclipse.
My application is not loading and it gives me an error "The application has stopped unexpectedly".
Sometimes if I change the target AVD in the run configuration to 1.6 instead of 2.0 it gives me the error "launch error sad result from adb".
All I need to do is establish a tcp/ip connection between the client and server and read some data from the server.
Can anyone please help me on this? I am stuck with this issue for long time.
I checked the log cat console. There was a null pointer exception from the thread which I started. I handled that and ran the application again. Still it is giving me the same error. I am wondering if I am doing anything wrong in specifying the ip address or port number in the android client. Can anyone ensure whether it (what I mentioned in my initial post about ip) is correct or not?
Because the same program if I run it as a standalone Java application it reads the data from the server without any issues.
Is the android emulator's ip address is the same as my machine's ip address?
Joined: Mar 22, 2005
There was a null pointer exception from the thread which I started. I handled that and ran the application again. Still it is giving me the same error.
What do you mean by "handled"? If you handle an NPE then it can't happen because you'd be checking the object for being null before calling a method on it.
Joined: Jun 08, 2009
Yes I did the same thing. In my case I am reading data from the DataInputStream in a background thread. So I am checking if in.available() > 0 inside run() method.
After doing this, I reran the application. It gives the same error but when I check logcat it doesn't show anything.