Python program for file sharing using socket programming (client-server file sharing)
File: server.py
importsocket,osserver_socket=socket.socket(socket.AF_INET,socket.SOCK_STREAM,0)server_socket.bind(("192.168.122.1",5000))server_socket.listen(5)print("TCP server waiting for client on port 5000")while1:client_socket,address=server_socket.accept()print("Connection established at",address)name=input("Enter text-file name to send ")path=os.path.join(os.getcwd(),name)file1=open(path,'rb')data=file1.read(1024)whiledata:client_socket.send(data)data=file1.read(1024)client_socket.close()print("File sent!")break;
kodingwindow@kw:~$ hostname -i | awk '{print $3}'
192.168.43.44
kodingwindow@kw:~$ python3 server.py
TCP server waiting for client on port 5000
Connection established at ('192.168.43.44', 47058)
Enter text-file name to send kw.py
File sent!
Dear User, Thank you for visitng Kodingwindow. If you are interested in technical articles, latest technologies, and our journey further, please follow us on LinkedIn.
Dear User, We are grateful for your interest in the Kodingwindow Android app. We intend to soon make it available on the Google Play Store. Currently, Android versions 10 and up require manual apk installations. Would you like to get the app?