0% found this document useful (0 votes)
12 views3 pages

Assignment 2

Assignment

Uploaded by

omerasif02
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views3 pages

Assignment 2

Assignment

Uploaded by

omerasif02
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

NAME: MUHAMMAD UMER ASIF

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()

You might also like