Assignment 2
Assignment 2
REG NO:2020372
QUESTTION NO.1:
QUESTION NO.2:
TCP_Program:
import socket
def Start_Server(host='127.0.0.5', port=4440):
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as server_socket:
server_socket.bind((host, port))
server_socket.listen()
print(f"Server is listening on host: {host}: with port :{port}")
while True:
Connection, address = server_socket.accept()
with Connection:
print(f"Connected with address: {address}")
while True:
data = Connection.recv(1024)
if not data:
break # If data is not available
print(f"Received information : {data.decode('utf-8')}")
# logic to send a response back to the client:
if __name__ == '__main__':
Start_Server()