Experiment 13
Experiment 13
Write a Program to connect server with client and passes information from one system to
another and vice versa that by creating / establishing connection
def start_server():
# Create a socket object
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
while True:
# Wait for a connection from a client
client_socket, addr = server_socket.accept()
print("Got a connection from", addr)
def start_client():
# Create a socket object
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
Expected Results:
The client and server successfully exchange messages. The server receives a message from the
client and responds back with a predefined message.
You should see the following output on the server:
pgsql
Copy
Server listening on port: 12345
Got a connection from ('127.0.0.1', <port_number>)
Received from client: Hello from the client!
The client should output:
pgsql
Copy
Received from server: Hello from the server!