import socket # Create a socket object server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Bind the socket to a specific address and port server_address = ('localhost', 12345) server_socket.bind(server_address) # Listen for incoming connections (max 5 connections in the queue) server_socket.listen(5) print("Server is listening for connections...") while True: # Wait for a connection client_socket, client_address = server_socket.accept() print(f"Connection established with {client_address}") # Send a welcome message to the client welcome_message = "Welcome to the server!" client_socket.send(welcome_message.encode()) # Close the connection with the client client_socket.close()