Computer Network Exp 8 20BCS6058
Computer Network Exp 8 20BCS6058
Computer Network Exp 8 20BCS6058
2. Tasks to be done:
3. Algorithm/Steps of Experiment:
Socket are generally employed in client server applications. The server creates a
socket, attaches it to a network port address then waits for the client to contact
it. The client creates a socket and then attempts to connect to the server socket.
When the connection is established, transfer of data takes place.
c. TCP:
Transmission Control Protocol (TCP) is a standard that defines how to establish
and maintain a network conversation by which applications can exchange data.
TCP is important because it establishes the rules and standard procedures for
the way information is communicated over the internet. It is the foundation for
the internet as it currently exists and ensures that data transmission is carried
out uniformly, regardless of the location, hardware or software involved.
5. Coding:
a. Server.py
import socket as skt
try:
server_socket = skt.socket(skt.AF_INET, skt.SOCK_STREAM)
server_socket.bind(("localhost", 9876))
except:
print("Error while creating a server socket")
except:
print("Error while connecting to the client")
print(f"Received:", received)
sending_message = "Hello " + received
client_socket.send(bytes(sending_message, "utf-8"))
client_socket.close()
b. Client.py
import socket as skt
try:
client_socket = skt.socket(skt.AF_INET, skt.SOCK_STREAM)
except:
print("Error while creating the socket")
try:
client_socket.connect(("localhost", 9876))
except:
print("Error while connecting to the server")
client_socket.send(bytes(name, "utf-8"))
received_message = client_socket.recv(1024).decode()
print(received_message)
6. Result/Output/Writing Summary:
Evaluation Grid (To be created as per the SOP and Assessment guidelines by the faculty):