app client (android java) - server (python)
<p>I need to establish a communication between an android application and a server in Python with sockets.</p>

<p>The client send a photo end the server reply with a string.</p>

<p>Here is my Server code:</p>

<pre><code>import socket
import os
import subprocess

s = socket.socket()
host = "10.255.20.186" # Get local machine name
port = 9090                # Reserve a port for your service.
s.bind((host,port))
s.listen(4)    #number of people than can connect it

# os.system("python C:\\Users\\Federica\\PycharmProjects\\client-server\\Client2.py")

sc, address = s.accept()
print "Connected by: " , address
sb = 'C:\\Users\\Federica\\PycharmProjects\\client-server\\ricevi'

#os.chdir(sb)
fln=sb + os.sep + sc.recv(8)        #read the name of the file
print fln
f = open(fln,'wb')                  #create the new file
size = sc.recv(5)                   #receive the size of the file
#size=size[:7]
print size
strng = sc.recv(int(size))          #receive the data of the file
#if strng:
f.write(strng)                      #write the file
f.close()

# here I send the photo to Matlab
cmd = '"matlab" -wait -nodesktop -nosplash -minimize -r "cd C:\\Users\\Federica\\PycharmProjects\\client-server\\; somma(\''+ fln + '\'); exit;"'

subprocess.call(cmd, shell=True)

imgPath = "C:\\Users\\Federica\\PycharmProjects\\client-server\\ricevi\\nuova.png"
print os.path.isfile(imgPath)
#subprocess.call('start \'' + imgPath + '\'')

sc.close()
s.close()
</code></pre>

<p>I was able to do it to communicate with a client in python but now I have to make the client in Android.
How can I do?</p>