How to make a simple chat application in python on Android

How to make a simple chat application in python on Android:

Chat app: it is a program in Wich two or more user interact with one another.



We will use socket module for programming:

Simply open your pydroid IDE and go to pip section and simply install socket library.
And then go to the editor and write following code.
This code for server:

import socket

s=socket.socket(socket.AF_INET,socket.SOCK_STREAM,0)

s.bind(("123.0.0.1",7000))

s.listen(3)

conn,adr=s.accept()

while True:

    d= input(" ")

    conn.send(bytes(d, encoding='utf-8'))

    print(conn.recv(1024))
This code for client:

import socket
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM,0)
s.connect(("123.0.0.1",7000))
while True:
    d= input(" ")
     print(conn.recv(1024))
    conn.send(bytes(d, encoding='utf-8'))
   


Comments

Popular posts from this blog

Scopes and opportunities in programming

Wich language should I learn for becoming a game devloper

What are game engine? Wich is best?