Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Python socket program Server/ Client with Android Client
****************** Server ********************
import socket
import sys
HOST = '' #this is your localhost
PORT = 8888
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#socket.socket: must use to create a socket.
#socket.AF_INET: Address Format, Internet = IP Addresses.
#socket.SOCK_STREAM: two-way, connection-based byte streams.
print 'socket created'
#Bind socket to Host and Port
s.bind((HOST, PORT))
except socket.error as err:
print 'Bind Failed, Error Code: ' + str(err[0]) + ', Message: ' + err[1]
print 'Socket Bind Success!'
#listen(): This method sets up and start TCP listener.
print 'Socket is now listening'
while 1:
conn, addr = s.accept()
print 'Connect with ' + addr[0] + ':' + str(addr[1])
buf = conn.recv(64)
print buf
import socket
import sys
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('', 8888)) #IP is the server IP
for args in sys.argv:
if args == "":
args = 'no args'
s.send(args + ' ')
print 'goodbye!'
Copy link

Dude I have to turn the Clint into a apk?

Copy link

Yes how do we turn it into an apk simply...?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment