To write a PYTHON program for socket for HTTP for web page upload and download
1.Start the program.
2.Get the frame size from the user
3.To create the frame based on the user request.
4.To send frames to server from the client side.
5.If your frames reach the server it will send ACK signal to client otherwise it will send NACK signal to client.
6.Stop the program
import socket
port = 60000
s = socket.socket()
host = socket.gethostname()
s.bind((host, port))
s.listen(5)
print("Server listening on port", port)
while True:
conn, addr = s.accept()
print("Connected to", addr)
data = conn.recv(1024)
print('Server received', repr(data))
filename = 'D:\\CSE-IOT\\Computer Networks\\Projects\\Ex_3c\\sample.txt'
with open(filename, 'rb') as f:
l = f.read(1024)
while l:
conn.send(l)
print('Sent', repr(l))
l = f.read(1024)
print('Done sending')
conn.send('Thank you for connecting'.encode())
conn.close()
Thus the socket for HTTP for web page upload and download created and Executed