I am finished with an Android client code, its working; and for the time being the data that was supposed to be received from apache http server was emulated to get data from sd card.
Now, I am working on the server side code in Python, using the socket library; and testing the default socket example from python socket documentation.
The problem I am facing is that the Android client can’t connect to this server side code.
Android side code trying to connect:
urlString = "http://10.0.2.2/cgi-bin/serverconnect.py";
URL url = new URL(urlString);
URLConnection conn = url.openConnection();
HttpURLConnection httpConn = (HttpURLConnection) conn;
try{
httpConn.connect();
......
}
Where serverconnect.py is:
# Echo server program
import socket
HOST = '127.0.0.1' # Symbolic name meaning all available interfaces
PORT = 80 # Arbitrary non-privileged port
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(1)
conn, addr = s.accept()
print 'Connected by', addr
while 1:
data = conn.recv(1024)
if not data: break
conn.sendall(data)
conn.close()
Clues, and hints are required from experts…
Thanks
The initial problem with this code is solved, which was the target Android version was 3.x +
So I needed to use a different thread for the network access. Have started a new thread with a different problem so thanks everyone for responding.